views:

188

answers:

9

I'm creating a (Java) class to represent an object in a musical score that has a specific onset time, and possibly a duration as well. I need a good name for this class. Is something like "Timed" or "TimedObject" appropriate? I've tried to come up with something that ends in "-able" (like Runnable) but I can't think of anything good; "OnsetTimeable" sounds silly, because "OnsetTime" isn't a verb. I don't really like "MusicalObject" either since that doesn't imply the object has an onset time (a "musical object" could be anything related to the score).

Update: Musically, this class represents an abstraction of something that happens at a point in time in the score. This is supposed to be the superclass of classes like Note, KeyChange, MeterChange, DynamicMarking, TempoMark, etc.

A: 

What is the main service (or services) your object is supposed to propose to the rest of your system ?

I believe its name should represents the abstraction you want to make by designing it in the first place.

So far, we know what your object is made of (an onset times, ...), but we do not know what is does, and more importantly as baash05 points out, what it is: in a word, what it represents.

As mentioned in the question What’s the best approach to naming classes?, the single responsibility principle can also be a good approach.

If it must represent some common structure of any characteristics of a score (note, ...), a name like ScoreAttribute could be appropriate.

VonC
A: 

What is it, musically?

Is it a note? -> good name: "Note", or "TimedNote"
Is it a phrase? -> good name: "MusicalPhrase", or "Phrase"
etc.

Don't abstract the object from its context (for example, naming it "Timed"); choose a name thinking of what the object really is and what is its use in your program.

friol
Musically, it represents an abstraction of something that happens at a point in time in the score. This is supposed to be the superclass of classes like Note, KeyChange, MeterChange, DynamicMarking, TempoMark, etc.
serenader
Key change and the like sound like elements of the song object not specific to a note. I mean if you play a note on it's own it doesn't know it's a change in meter or key. If you do it this way you're making the note responsible for something the song should take care of. It breaks OO design rules
baash05
A: 

How about Temporal? Or TimedFigure, TemporalFigure ?

Bedwyr Humphreys
A: 

We don't need to know what your object does.. Any more then we need to know what class type "Cat" does.. (mine does very little, but I'd be loathed to create a SleepsAndPoops class)
The class name is what it "is".
Where is the need for a verb? dialog, stack, string, pen... I dont see a verb in any of their names?

I'd go with MusicNote..
All musical notes have a time element.. Really. Have you ever heard a note that didn't have a time element to it?

Then a MusicPhrase could have an array of MusicNotes and a MusicSong could have an array of phrases. MusicAlbam could have an array of MusicSongs..
I know I know a song is by definition musical but the name helps keep them together.

baash05
better put than in my answer ;) +1
VonC
This is meant to be a superclass of things like key changes as well, which are not types of musical note
Bedwyr Humphreys
making it a super class to both a note and a key change (which is an element of a song) is crazy. A note should have no idea about key change and such.. I think he's making a mistake trying to super with this object.
baash05
To extend.. A keychange doesn't fall under the "is a". A phrase might "have a" key change in it, but it's not an "is a".
baash05
A key change is both a written musical symbol and an event in the score.
Bedwyr Humphreys
A: 

ScoreItem? MusicalEvent?

JW
A: 

I concur with the others answering this thread; I'd generalize.

Think of creating a class, say named "TimedAction". This can be parameterized to do some sort of Action at a specified Time; then you simply tell the "TimedAction" what it's going to do at that time. This allows you to modify the Action, and gives you flexibility for other Actions that you may need to put in place.

The idea here is that you want something to happen at a given time. Instead of thinking of it as the somthing that you want to happen, think of it as the happening of something. Therefore, you create a class for happening "TimedAction" and parameterize the something. That's as opposed to your first instinct of creating a class for the something that has a happening.

McWafflestix
+4  A: 

This sounds like events in MIDI files.

divideandconquer.se
+1  A: 

Is it a class, or an interface? An interface should be driven by the needs of its callers. What can you do with an OnsetTimeable (calling it that for now)? Your tendency to propose names ending with -able suggests you think of it as an interface.

If you are only scoring music, rather than writing a program to play a score, I'd guess that most of the objects in the score would be more like simple data structures or "value objects" than true objects with operations. That's because when rendering an object (like onto a staff), encapsulation tends to be broken. This makes sense, because the point of rendering or serialization of an object is to capture all of its state. In this case, using concrete POJOs is probably sufficient.

erickson
A: 

It sounds like you may be describing a Section, or perhaps a Movement.

Erick B