Results 1 to 7 of 7
  1. #1
    BustTheCode is offline Member
    Join Date
    Sep 2013
    Posts
    11
    Rep Power
    0

    Default Naming my classes? Is it a manager, a model, a service?

    Hey everyone, so I'm working on a music notation/analysis program for practice because I'm a masochist who seems to enjoy biting off more than he can chew. I've finally figured out/developed some algorithms to mathematically represent notes and modulate keys without having to program each individual scale, but to do so, I'm working on something akin to a "helper" class.

    Based on the algorithm I designed and the way I'm numerically representing notes, there are a lot of steps involved in having the program figure out whether a note is sharp or flat given whatever the scale and/or key is. My solution so far then, has been to design a music specific algorithm class that takes numeric arguments and converts them to notes represented as Strings. It's function is similar to the Math class only more specific to specific types of problems. This way every other class can just represent notes numerically which provides them a lot more flexibility and significantly limits code re-use.

    I've been researching a lot of design patterns, and I can't figure out what function/name this helper/algorithm class should actually be. I want to say it's a "model" class using the model-view-controller design method since it updates the presentation/output, but I'm not sure it does enough to justify being called a "model" class. I've ruled out "manager" and I believe I'm ruling out "service."

    So any thoughts? Thanks everyone!

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    7

    Default Re: Naming my classes? Is it a manager, a model, a service?

    I am just wondering:
    Your Notes are just plain Strings? Why didn't you create a Note class?
    Then you could have related methods in there e.g. creating a Note from other values sound like a constructor.

    MVC pattern has nothing to do with this in my eyes because that is just a pattern how to divide the GUI from the business classes so you can write easier tests.

    With kind regards,

    Konrad

  3. #3
    BustTheCode is offline Member
    Join Date
    Sep 2013
    Posts
    11
    Rep Power
    0

    Default Re: Naming my classes? Is it a manager, a model, a service?

    Quote Originally Posted by kneitzel View Post
    I am just wondering:
    Your Notes are just plain Strings? Why didn't you create a Note class?
    Then you could have related methods in there e.g. creating a Note from other values sound like a constructor.

    MVC pattern has nothing to do with this in my eyes because that is just a pattern how to divide the GUI from the business classes so you can write easier tests.

    With kind regards,

    Konrad
    Hey thanks for the reply and info on MVC. I didn't realize that I had misunderstood it to that degree :P.

    And Sorry for the late reply (right smack dab in the middle of finals), but this very issue of a Note class I have given a lot of consideration to and done a considerable amount of research into regarding our modern tonality and notation system. I do have a Note class, which defines a single note as being a degree (integer), a letter (String), and Strings signifying sharp, natural, or flat. The Note class however also determines duration, octave, whether or not it's dotted, and a plethora of other possible states that a note can be. The only thing that relates to a scale from the Note class, is the degree, the letter, and the sharp/flat/natural modifier since the Scale class is actually a set of rules to guide melodic and harmonic movement as well as interval/chord possibilities, not a collection of notes. The "Measure" class is what has a direct relationship to Notes while Scale simply determines how those notes can best be used, what is the stepwise motion from the tonic to the 7th note degree of the scale (based on what kind of scale it is), exc. I'm totally open to this being a poor design scheme, but it seemed to make the most sense to me. That's why my primary representation of notes within a scale are in degrees (where degree 0 = C, and one full 360 degree rotation across all 12 tones leads back to C).

    Based on my design, the primary way I've found to interacting with Notes and a collection of Notes is by using integer values representing degrees of rotation, since based on modern tonality, determining whether something is sharp or flat or natural is dependent on a plethora of conditions (is the movement ascending or descending, is it the dominant modulation from X note exc.. exc...), while using an integer degree system gives those note values without needing to define their sharp or flat state. I've taken this approach with the Note class as well, allowing the existence of Notes without requiring them to define letters (at least at this preliminary stage).

    Words cannot tell you how much I've learned about our modern western musical system by attempting this project. I've played the piano since I was 2 years old, and while I've always known the scale of C is all white notes with no sharps or flats, I've never realized A) that it's the "Center" of all other keys, and B) Sharps/flats, white keys/black keys, and the key of C are all completely arbitrary.
    Last edited by BustTheCode; 04-28-2014 at 07:04 PM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Naming my classes? Is it a manager, a model, a service?

    Quote Originally Posted by BustTheCode View Post
    The Note class however also determines duration, octave, whether or not it's dotted, and a plethora of other possible states that a note can be.
    I don't have anything I can actually say about your question, but I do have one of my own. Doesn't the fact that the note is dotted or not determine duration? Or do your notes know the BPM? I would consider that incorrect, as adjusting BPM should not require the code to adjust the duration of every note, IMO.

    Just caught my eye as I've been doing a tab player/editor to play all the scraps of guitar tabs my son seems to get from his tutor. All the other stuff about tonality, degrees etc is waaaaaay out of my field. :)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    BustTheCode is offline Member
    Join Date
    Sep 2013
    Posts
    11
    Rep Power
    0

    Default Re: Naming my classes? Is it a manager, a model, a service?

    Quote Originally Posted by Tolls View Post
    I don't have anything I can actually say about your question, but I do have one of my own. Doesn't the fact that the note is dotted or not determine duration? Or do your notes know the BPM?
    Fair question. The dot does effect duration (it's the note plus half it's durational value). The way I've designed it, the Note class has no need to know the BPM as the duration simply implies what fractional part of a measure the note takes up (a whole note getting 4 "counts," quarter note is 1/4 a whole note exc.). The BPM would likely be taken care of in the GUI level of the program (if I ever get that far) and parts dealing with audio playback.

    And that sounds like a really awesome little program you're working on. Oh, and the "degrees" thing is something I completely made up in order to have a numerical way of representing notes. I guarantee you I've made it much, much more complicated than it actually is haha.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Naming my classes? Is it a manager, a model, a service?

    Ah right, that makes more sense...:)
    We have similar concepts then.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: Naming my classes? Is it a manager, a model, a service?

    I would love to help and I do so love to share my opinion, but my unfamiliarity with the subject matter simply makes it impossible to really say anything useful here at all. A proper naming and class hierarchy comes from modeling after reality, and I don't understand the reality :)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Model classes
    By Etherguide in forum New To Java
    Replies: 3
    Last Post: 02-15-2011, 10:53 PM
  2. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 02:19 AM
  3. Naming a Class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-22-2007, 11:21 AM
  4. EJB, classes Model
    By Felissa in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-06-2007, 03:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •