Prefix or suffix? [modified * 2]
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
a long long time ago, in a galaxy far far away, we did something similar. I came in after the design phase so had no input, but the method they used was to have properties (C#) for the 'phase'
obj.current.Correlation // or just obj.Correlation obj.historic.Correlation obj.historic[1927].Correlation obj.future[2].Correlation
As you're using get / set, I assume you are not C# but this can be applied to other languages? Never really thought about good or bad design - it was easy to code against, and with the indexers giving the offset, was fairly flexible. I'd give you a really good answer but then that turns into 'code' and I am not doing that in the lounge - i'd drop this in the Design / Architecture forum.Knowledge is hereditary, it will find its way up or down. - Luc Pattyn
so you answer don't be scared of failure The only failure is never to try Things You've Never Done - Passenger -2008 -
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
It depends. If I'm coding primarily for myself, and making heavy use of Intellisense, I tend toward using a prefix for grouping, and since historic seems more of a variant of correlation than correlation a variant of historic, I would place correlation first. If I'm coding 'for the public' I would say getHistoricCorrelation, as it has a more naturally descriptive nature.
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
Vikram A Punathambekar wrote:
getHistoricCorrelation()
Is more readable IMO However, if you have a lot of differetn Correlations, then the suffix means you get a list of possible options in intellisense. I hate writing code for the intellisense benefits tho, it feels like the wrong thing to be driving the coding style.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
GetHistoricCorrelation()
would be my choice. As CG already said, it sounds more meaningful to me.Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Vikram A Punathambekar wrote:
getHistoricCorrelation()
Is more readable IMO However, if you have a lot of differetn Correlations, then the suffix means you get a list of possible options in intellisense. I hate writing code for the intellisense benefits tho, it feels like the wrong thing to be driving the coding style.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Christian Graus wrote:
However, if you have a lot of differetn Correlations, then the suffix means you get a list of possible options in intellisense.
Not quite. You have a lot of different types (I only listed 3) and they are all either live or historic. I used historic as a suffix because it only modifies the Correlation, or SpreadCurve, or whatever you need.
Christian Graus wrote:
Vikram A Punathambekar wrote: getHistoricCorrelation() Is more readable IMO
In isolation, I agree. But I think
getCorrelation()
andgetCorrelationHistoric()
look better as a pair thangetIndexCurve()
andgetHistoricIndexCurve()
.Christian Graus wrote:
I hate writing code for the intellisense benefits tho, it feels like the wrong thing to be driving the coding style.
Actually, when you design/write an API, coding for Intellisense is a huge plus, if not a must. Obviously, I'm not talking about the implementation details of your methods here, but rather the names you choose for them.
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
-
GetHistoricCorrelation()
would be my choice. As CG already said, it sounds more meaningful to me.Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Please see my reply to CG above.
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
-
a long long time ago, in a galaxy far far away, we did something similar. I came in after the design phase so had no input, but the method they used was to have properties (C#) for the 'phase'
obj.current.Correlation // or just obj.Correlation obj.historic.Correlation obj.historic[1927].Correlation obj.future[2].Correlation
As you're using get / set, I assume you are not C# but this can be applied to other languages? Never really thought about good or bad design - it was easy to code against, and with the indexers giving the offset, was fairly flexible. I'd give you a really good answer but then that turns into 'code' and I am not doing that in the lounge - i'd drop this in the Design / Architecture forum.Knowledge is hereditary, it will find its way up or down. - Luc Pattyn
so you answer don't be scared of failure The only failure is never to try Things You've Never Done - Passenger -2008Sorry, I think I should have been more specific. This is a web service, and these methods go to the database to fetch the requested data. The class containing these methods does not hold any data, hence I can't use properties. Besides, this is in Java.
Malcolm Smart wrote:
I'd give you a really good answer but then that turns into 'code' and I am not doing that in the lounge - i'd drop this in the Design / Architecture forum.
Honestly, I don't know why some people are paranoid about posting any code in the Lounge. After all, this question is simply about suffixes versus prefixes - surely something as innocuous as this doesn't warrant the Arch forum? On a lighter note, the rules only say no programming questions. They don't say no programming answers. ;)
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
So you are 'defaulting' to Live, and Historic is an option, so to speak? I think, its best to use either no defaults, thus creating
GetLiveCorrelation(); GetHistoricCorrelation();
which seems clearer to me and is less implicit. Or maybe you put it into different services. Somehow, I feel you are creating a decorator/wrapper of what could easily be two interfaces. For some reason, I really dislike the suffix option, especially when paired with the default option of leaving 'live' out. Cheers, Chris"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles Blog -
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
I prewfer top own (e.g. ZoomIncrease, ZoomDecrease, AxisRangeIncrease, AxisRangeDecrease) over the 'correct' but in my view struxturally garbled IncreaseZoo, DecreaseZoom, IncreaseAxisRange etc. This simply helps with orientiiton, and works better with IDE tools (class browser, intellisense etc.) For your example, I can't derive however if "Historic" would make a sensible group. (Of course it would even be better to have this as subobjects: Zoom.Increase, Zoom.Decrease, etc. but that wasn't the question, right? right?)
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist -
Christian Graus wrote:
However, if you have a lot of differetn Correlations, then the suffix means you get a list of possible options in intellisense.
Not quite. You have a lot of different types (I only listed 3) and they are all either live or historic. I used historic as a suffix because it only modifies the Correlation, or SpreadCurve, or whatever you need.
Christian Graus wrote:
Vikram A Punathambekar wrote: getHistoricCorrelation() Is more readable IMO
In isolation, I agree. But I think
getCorrelation()
andgetCorrelationHistoric()
look better as a pair thangetIndexCurve()
andgetHistoricIndexCurve()
.Christian Graus wrote:
I hate writing code for the intellisense benefits tho, it feels like the wrong thing to be driving the coding style.
Actually, when you design/write an API, coding for Intellisense is a huge plus, if not a must. Obviously, I'm not talking about the implementation details of your methods here, but rather the names you choose for them.
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
Look at a bunch of functions like:
GetWindowName(), GetWindowClass(), GetWindowState(), SetWindowPos()
. Window is an entity here and these functions are performing some action (or querying it for its own state information) on it to yield some result. I generally don't put the entity/type that I am performing an action upon at the end (of course, there can be something likeGetWindow()
, but that's different). Historic data (is that the term :~ ) is an entity in your case and you may perform various actions on it, like getting the index curve of it, getting the correlation, etc., Similarly, live data is another entity. So, we've got two different entities and we you shall build up functions around them. :) Of course, I know there may be exceptions and I'm just talking in general.Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
Vikram A Punathambekar wrote:
getHistoricCorrelation()getHistoricRollDate()
As the function gets the historic correlation data, it makes sense to name it GetHistoricCorrelation.
You have, what I would term, a very formal turn of phrase not seen in these isles since the old King passed from this world to the next. martin_hughes on VDK
-
So you are 'defaulting' to Live, and Historic is an option, so to speak? I think, its best to use either no defaults, thus creating
GetLiveCorrelation(); GetHistoricCorrelation();
which seems clearer to me and is less implicit. Or maybe you put it into different services. Somehow, I feel you are creating a decorator/wrapper of what could easily be two interfaces. For some reason, I really dislike the suffix option, especially when paired with the default option of leaving 'live' out. Cheers, Chris"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles Blog:doh: I must have read your reply before I replied to Vikram. I've suggested the same thing, but I think my explanation is far more confusing.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Look at a bunch of functions like:
GetWindowName(), GetWindowClass(), GetWindowState(), SetWindowPos()
. Window is an entity here and these functions are performing some action (or querying it for its own state information) on it to yield some result. I generally don't put the entity/type that I am performing an action upon at the end (of course, there can be something likeGetWindow()
, but that's different). Historic data (is that the term :~ ) is an entity in your case and you may perform various actions on it, like getting the index curve of it, getting the correlation, etc., Similarly, live data is another entity. So, we've got two different entities and we you shall build up functions around them. :) Of course, I know there may be exceptions and I'm just talking in general.Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Hey Rajesh, obvioulsy we agree on this :-) I just read a few lines of "Code Complete 2" about naming methods: "To name a procedure, use a strong verb followed by an object" As you pointed out already, "Get" is already a strong verb - so the real question here is whether "Correlation" itself can be regarded as an entity - but that requires some knowledge about the subject matter (which I don't have). However, in "Code Complete", Steve McConnell also points out that in an OO-environment, the method itself does not need to include the object name, because it is included in the invocation such as
myHistoricData.GetCorrelation()
. I think I'd still go for this, if possible. On the other hand, that might raise question whether to name the class/webService "financialDataHistoric" or "historicFinancialData"... Chris"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles Blog -
Hey Rajesh, obvioulsy we agree on this :-) I just read a few lines of "Code Complete 2" about naming methods: "To name a procedure, use a strong verb followed by an object" As you pointed out already, "Get" is already a strong verb - so the real question here is whether "Correlation" itself can be regarded as an entity - but that requires some knowledge about the subject matter (which I don't have). However, in "Code Complete", Steve McConnell also points out that in an OO-environment, the method itself does not need to include the object name, because it is included in the invocation such as
myHistoricData.GetCorrelation()
. I think I'd still go for this, if possible. On the other hand, that might raise question whether to name the class/webService "financialDataHistoric" or "historicFinancialData"... Chris"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles BlogChristoph Menge wrote:
myHistoricData.GetCorrelation()
I was thinking of a situation where you're writing this API on the global namespace. So, it made perfect sense to me to have names like
::GetHistoricCorrelation()
and::GetCurrentCorrlation()
. Of course, it were a member function, thenGetCorrelation()
is sweet enough. :) On the perverted side, we can have an overload like::GetCorrelation(Entity E)
if we have too may entities on which we could possibly make this call. :-ONobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Look at a bunch of functions like:
GetWindowName(), GetWindowClass(), GetWindowState(), SetWindowPos()
. Window is an entity here and these functions are performing some action (or querying it for its own state information) on it to yield some result. I generally don't put the entity/type that I am performing an action upon at the end (of course, there can be something likeGetWindow()
, but that's different). Historic data (is that the term :~ ) is an entity in your case and you may perform various actions on it, like getting the index curve of it, getting the correlation, etc., Similarly, live data is another entity. So, we've got two different entities and we you shall build up functions around them. :) Of course, I know there may be exceptions and I'm just talking in general.Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Rajesh R Subramanian wrote:
Historic data (is that the term ) is an entity in your case and you may perform various actions on it, like getting the index curve of it, getting the correlation, etc.
Au contraire. Correlation, IndexCurve, etc are entities, and I'm getting their historic (anything before today) and live (today's) values.
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
-
Hey Rajesh, obvioulsy we agree on this :-) I just read a few lines of "Code Complete 2" about naming methods: "To name a procedure, use a strong verb followed by an object" As you pointed out already, "Get" is already a strong verb - so the real question here is whether "Correlation" itself can be regarded as an entity - but that requires some knowledge about the subject matter (which I don't have). However, in "Code Complete", Steve McConnell also points out that in an OO-environment, the method itself does not need to include the object name, because it is included in the invocation such as
myHistoricData.GetCorrelation()
. I think I'd still go for this, if possible. On the other hand, that might raise question whether to name the class/webService "financialDataHistoric" or "historicFinancialData"... Chris"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles BlogChristoph Menge wrote:
the real question here is whether "Correlation" itself can be regarded as an entity
Yes. SpreadCurve, IndexCurve, Correlation, etc are the entities. I'm building functions to get their historic (anything before today) and live (today's) values.
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
-
Christoph Menge wrote:
the real question here is whether "Correlation" itself can be regarded as an entity
Yes. SpreadCurve, IndexCurve, Correlation, etc are the entities. I'm building functions to get their historic (anything before today) and live (today's) values.
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
Hi Vikram, what I meant is: "Is correlation alone a sufficient description for the entity, or is it necessary to call it liveCorrelation?". In essence, I prefer GetHistoricalCorrelation() over GetCorrelationHistorical() like most (all?) of the other posters did. Chris
"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles Blog -
Hi Vikram, what I meant is: "Is correlation alone a sufficient description for the entity, or is it necessary to call it liveCorrelation?". In essence, I prefer GetHistoricalCorrelation() over GetCorrelationHistorical() like most (all?) of the other posters did. Chris
"Obstacles are those frightening things you see when you take your Eyes off your aim" - Henry Ford
Articles BlogChristoph Menge wrote:
Is correlation alone a sufficient description for the entity, or is it necessary to call it liveCorrelation?
Actually, yes. A SpreadCurve is an entity by itself. The only thing that differentiates between live and historical SpreadCurves is that the historical ones are from previous days. Thanks for your input; I'm somewhat surprised (and somewhat pleasantly so) to see pretty much everybody actually disagrees. ;)
Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
-
I am designing an API, which will (amongst other things) provide live and historic values for many types of data. Let's say the data types will be
Correlation
,IndexCurve
, andRollDate
, amongst many others. The methods that get live data will be calledgetCorrelation()
,getIndexCurve()
, andgetRollDate()
respectively (the word**live**
will not be part of the name). Would you prefer the methods that deal with historic data (anything before today's data) to be calledgetCorrelationHistoric()
getRollDateHistoric()or
getHistoricCorrelation()
getHistoricRollDate()I strongly want to keep the modifier as the suffix (i.e.,
getCorrelationHistoric()
) but I'm interested in knowing what you would do, and why. :) [EDIT]If it makes any difference, these methods will be part of a web service. Written in Java ;) [/EDIT] [EDIT2]Added clarifications[/EDIT2]Cheers, Vikram.
"real dictators don't loose[sic] elections." - Diego Moita.
modified on Tuesday, February 26, 2008 7:15 AM
Are you really planning that these methods don't have any arguments? What about making the difference with some kind of overload? Something like:
getCoorelation() --current
getCorrelation(Date date) --historic correlation of dateRobert