Naming classes

Posted by goo on 16-Oct-2018 02:37

11.7

I wonder how I should do naming of classes. 

I have classes that is used on client site, where there are no db involved. I also have calsses where db is involved. If both classes involve i.e Customer, how would you name them?

I have used PROPATH (naming classes i.e. myClass) instead of using (oo.myclass), is that good or bad?

best regards, Geir Otto 

All Replies

Posted by Arno van der Ende on 16-Oct-2018 02:40

Depends what the classes do. But I would choose to separate them with different package names. Divide the client and server code.

Posted by Mike Fechner on 16-Oct-2018 02:44

Using PROPATH instead of USING is BAD! You basically create a second class name for the same thing. That will have severe impact at runtime.
 
We tend to name our classes with the subject (Customer) in the front and the type (e.g. BusinessEntity, Controller, View) on the end.

Posted by goo on 16-Oct-2018 02:49

Thanks, what about classes that do things like date converting, small methods that you are using in the daily, that is not connected to any db?

What about caption? should we use small (thinking of serverbased code that is placed on linux)...

Posted by Mike Fechner on 16-Oct-2018 02:54

DateConverter
DateHelper
 

Posted by goo on 16-Oct-2018 03:16

Aaah, but do you mean that we should have one class for each kind of convering? So numberconverting, dateconverting etc. should have one class each?
 
I have normally made a companymethods class, that does all the companyfunksjons that needs to be done. In there I have i.e. dateconvertings, numberconvertings etc.
 
Where should I start reading about this?
 
//Geir Otto
 

Posted by Mike Fechner on 16-Oct-2018 03:20

Single responsibility principle.
 
Avoid god-classes that can do everything. Use smaller more specialized classes.
 
The real art is where to draw the line 😊

Posted by jmls on 16-Oct-2018 03:24

each class should do one thing, and do it well. So I would have a namespace (folder!) of Converting with classes of Date, Number, String etc

Converting/Number.cls

def var convertingNumber as Converting.Number no-undo.

etc

Posted by Rutger Olthuis on 16-Oct-2018 03:28

A close buddy principe or the single responsibility principle is the Separation of Concerns principle.

I think it's good to google those two when starting with OO.

Also checkout the AutoEdge The Factory example or (if you have access to them) the OO courses on the Progress website. It might answer a few of these questions for you.

Posted by goo on 16-Oct-2018 04:34

Thanks everyone, I will do so 😊
 
//Geir Otto
 

This thread is closed