Class names and colisions of names

Discussion related to the Cross Codebot open source framework
mdbs99
Posts: 4
Joined: Thu Mar 26, 2015 1:53 am
Location: Rio de Janeiro / Brazil
Contact:

Class names and colisions of names

Postby mdbs99 » Thu Mar 26, 2015 2:04 am

Hi Anthony,

Today I had cloned the sources. A quick look at the code, I realized that all classes have simple names (without prefix as Rx, Jv, etc.) without defining which framework belongs. Whereas Lazarus does not allow to install components with the same name - which I consider a mistake, because the unit should be used as namespace - how can you don't have colisions of names with other components, both Lazarus and third?

Thanks.

sysrpl
Posts: 108
Joined: Thu Feb 05, 2015 6:31 pm

Re: Class names and colisions of names

Postby sysrpl » Thu Mar 26, 2015 4:00 am

I can only guarantee that my component class names won't clash with the LCL component class name, but this shouldn't be a problem, as the majority my classes are non visual, which will be unaffected by by this type of problem.

If the case arises that some new LCL bundled component classes with the name of something I've already created, then at that point I will rename the class.

I understand the notion of class prefixes, but will never use them as I prefer cleanly named code

TUrl or TcbUrl
TFtpClient or TcbFtpClient
TDetailList or TcbDetailList

I'll take the former naming convention everytime.

mdbs99
Posts: 4
Joined: Thu Mar 26, 2015 1:53 am
Location: Rio de Janeiro / Brazil
Contact:

Re: Class names and colisions of names

Postby mdbs99 » Thu Mar 26, 2015 8:20 pm

sysrpl wrote:I can only guarantee that my component class names won't clash with the LCL component class name, but this shouldn't be a problem, as the majority my classes are non visual, which will be unaffected by by this type of problem.

Yes, for non visual components this problem is minimized.

If the case arises that some new LCL bundled component classes with the name of something I've already created, then at that point I will rename the class.

...and all user code will need to be updated too. If this component is visual, *.lfm is other problem.

I understand the notion of class prefixes, but will never use them as I prefer cleanly named code

TUrl or TcbUrl
TFtpClient or TcbFtpClient
TDetailList or TcbDetailList

I'll take the former naming convention everytime.


I agree a cleanly named code is better, visually, but all frameworks are used in user-code and, many times, together with others frameworks. So, if my unit has two 'uses' for others units that have TUrl class... colision name.
Ok, that is not a big problem because methods could be little different and the programmer will see... but you use simple names even to functions. In Bare.Game you have a bare.system unit that have many functions. Many of them have the same names as the FCL. In these cases the compiler will compiles with no error, but which function should be used in user code, FCL or Bare.Game? See my point?

Do you have -- still in Bare.Game -- TStream class, TFileStream class, so on.
I'm not criticizing you. I just want understand how I can codify using simple names, like you, but not thinking in these language problems.

PS: I've checked "Notify my when a replay..." but I didn't received any mail. :(

sysrpl
Posts: 108
Joined: Thu Feb 05, 2015 6:31 pm

Re: Class names and colisions of names

Postby sysrpl » Thu Mar 26, 2015 8:31 pm

Bare Game is meant not to be used with any other library. It is meant to be minimally dependent library, for maximum platform compatibility (Android, iOS). There is no SysUtils unit, there is no Classes unit, there is only SDL2 imports, Posix imports for non Window, a few imports for Windows, and the units of Bare Game itself.

Bare.System defines TThread, TStream, FileOpen, StrFunctions, FormatFunctions, ect. in such a way as to only rely on only those things which are absolutely necessary, and thus I've been able to get Bare Game working on iOS, Android, and even the Ouya console. I was last adding in optional hooks for Steam greenlight. When I have the time, and more community members to test, I'll roll out V2 to users for testing.

Note: The email notification for this forum are currently not working.

mdbs99
Posts: 4
Joined: Thu Mar 26, 2015 1:53 am
Location: Rio de Janeiro / Brazil
Contact:

Re: Class names and colisions of names

Postby mdbs99 » Thu Mar 26, 2015 8:40 pm

Ok about Bare Game...

But what are its arguments about these problems using Codebot?
Example: If you need Threads in Codebot, but need customize the TThread class, what name do you will choose for the new class?

Thanks.

Xirax
Posts: 55
Joined: Sat Mar 07, 2015 11:16 am

Re: Class names and colisions of names

Postby Xirax » Thu Mar 26, 2015 8:51 pm

mdbs99I think you are right but former naming is not a problem until library have power to be a project leader an CodeBot are going to be it.otherwise it can be pain.

sysrpl
Posts: 108
Joined: Thu Feb 05, 2015 6:31 pm

Re: Class names and colisions of names

Postby sysrpl » Thu Mar 26, 2015 9:55 pm

mdbs99 wrote:Example: If you need Threads in Codebot, but need customize the TThread class, what name do you will choose for the new class?


I name them like TAnimationThread = class(TThread) or TMouseThread = class(TThread) (which exist in the library, just search). My naming is very intentional, all you have to do is search package source code and you'll find the answers (Lazarus has a find in files current package/project function).

A deep inheritance example from the sources:

TDetailsList -> TCustomDrawList -> TScrollList -> TRenderCustomControl -> TCustomControl

A shallow inheritance example from the sources:

TSurfaceBitmap -> TGraphic

acemary
Posts: 1
Joined: Tue Oct 13, 2015 12:28 pm

Re: Class names and colisions of names

Postby acemary » Wed Oct 14, 2015 11:31 am

Ugly. I'd rename the class to avoid the java.lang collision first. Compiler is very generic. You could make it more specific and clearer pretty easily....http://www.trainingintambaram.in/ccna-t ... nnai.html#


Return to “Cross Codebot”

Who is online

Users browsing this forum: No registered users and 1 guest

cron