I wouldn't say I'm very used to all of them, but Interfaces / Protocols turned out to be one of the most useful. Basically every time you want different objects (from different classes) to do the same thing (like show them on a map. draw them on a canvas, save/load/… them in a database, etc) it scream for an interface.Some programmers are very used to Object Oriented Programming (OOP) concepts
To achieve this, I usually create a class with methods and properties common to the classes that have to use them.I wouldn't say I'm very used to all of them, but Interfaces / Protocols turned out to be one of the most useful. Basically every time you want different objects (from different classes) to do the same thing (like show them on a map. draw them on a canvas, save/load/… them in a database, etc) it scream for an interface.
Sure do - it's your fault I'm pestering people here … ?You may know me (Alain Bailleul, Alwaysbusy) from the Xojo and ifNotNil forums.
For translations I highly recommend the free to personal use DeepL - MUCH better than Google Translate or Microsoft's Translator. The German / English translations are so good that I hardly ever have to correct anything.I don't know if I was able to explain myself in a simple way because I am in translation and sometimes the meaning is not always clear.
P.S. In my opinion Xojo is going the wrong way, and if they don't fix their "we are introducing more bugs each release than we can fix" problem (and I don't see them doing that) then B4 will be the logical escape route (and it was the maturity and stability of the underlying Java that convinced me to give it a try).Especially one with an exotic language like Xojo
I still write a lot of things in Java too. B4X is the fast and 'easy-to-use' glue. For example, for BANano, Inheritance in Java has saved me many hours to write the framework. It would've been perfectly possible to write it in B4X itself, but as of the size of the lib, I decided to write it in Java anyway. And now I can just make full use of this framework in B4X, which speeds up programming considerably compared with having to do it ALL in Java.straight to Java
How would that work with my CanDrawItself example with cHeader, cDepartment, and cEmployee classes? You can add an instance of the "common class" (let's call it CanDrawItself) to the cHeader, cDepartment, and cEmployee classes, but how do you make them act differently? As far as I understand you can only override a method in a subclass. Or does your "common class" method accept any object as a parameter, and you have a long select case statement on what to draw for each cHeader, cDepartment, and cEmployee class etc that might be passed in as parameter?To achieve this, I usually create a class with methods and properties common to the classes that have to use them.
Within the classes in question I create an instance of the common class. This way it can also make it act differently based on the calling class.
Being cross-platform would definitely be an asset and Erel has explained it has to do with some .NET components it uses. Hopefully one day this can be done and it may convince some Mac/Linux users to make the jump. I would however prefer it doesn't if that would mean we (on Windows) would loose functionality. The IDE may look a bit 'spartan' but if prefer it every day over the clickety-click IDE of Xojo (my poor wrists! ? ). I'm very used to the Eclipse IDE in Java so in my case it is seemingless to switch between them. I even changed the color schemes to be the same.It is neither cross-platform nor as polished as it could be.
Those are indeed forces to be reckoned with, but (unlike Xojo) B4X has always been on top of things with the big boys. It being so light-weight, extremely stable and reliable I'm not worried at all: It will not go into the same spiral of doom like Xojo's REALBasic to Xojo transition. Your prediction with RB was spot on and I also was very glad we did the move for Xojo to B4X right before everything went into smithereens.Microsoft, Google, even Apple
You are looking for a cross platform development environment and you do not want to lose your existing program code. There are people who only program for Android smartphones in B4A. There is nothing wrong with that, but there lies the challenge to also keep those people "on board" while offering others who do have a need for it a cross platform development environment.But B4's has a big downside (in my opinion): its IDE. It is neither cross-platform nor as polished as it could be.
This is my idea.Or does your "common class" method accept any object as a parameter, and you have a long select case statement on what to draw for each cHeader, cDepartment, and cEmployee class etc that might be passed in as parameter?
Actually, as the code is in the object anyway, it might be better to pass two enums, one of the type of class (eg enumObjectsThatCanDrawThemselves or enumDrawingObjects or enumPainters), another for what to draw. That would prevent invalid objects being passed in, but still confer the same information."common class" method accept any object as a parameter,
Xojo | Swift | B4 |
Interface | Protocol |
Secondly there no such thing as a stupid question in this community, just another question.So I'm going to ask a lot of stupid questions,
Alain explained that B4 uses composition instead of interfaces, so that was certainly good advice (even though it is not completely correct as Interfaces are one elegant way of achieving composition, so they are not separate concepts).@alwaysbusy has given you the best advice as well as @Erel and @Star-Dust.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?