Maybe this:
<Action><Object><Attribute/State>();// Do an Action over some Object Attribute/State
This is how I tend to make my APIs, more info about this here:
raylib syntax analysis · raysan5/raylib Wiki (github.com)
Maybe this:
<Action><Object><Attribute/State>();// Do an Action over some Object Attribute/State
This is how I tend to make my APIs, more info about this here:
raylib syntax analysis · raysan5/raylib Wiki (github.com)
The second one BUT use classes with class (static) methods instead of unit names.
This way you *cannot* call method without specifying which.
And can pack several ones in the same unit
And move them between units if you need to change architecture -- without touching the calling code
in my engine:
GAPI.TexImage2d(p, format)
where
class function GAPI.TexImage2d(
image: pointer;
format: TGAPITextureFormat;
level: GLuint = 0;
width: GLuint = 0; // 0 = get from image
height: GLuint = 0; // 0 = get from image
CreateTextureObject: boolean = false
): GLuint; //no return value unless CreateTextureObject is true
There are a lot of nice advices here. Thanks to all.
Yes, I've learned that the hard way.
The injection thing is interesting but I think I'll not do that way.
That's a nice way. Maybe I should review my API now I'm (re)starting it.
I didn't realize I can do that. I did in some PHP projects but forgot completely there are also static class methods and properties in Pascal. Since I'll revisit my API I'll see how this may fit with the old-school I want to archieve.
No signature provided yet.
Well, I was working in this new API Chebmaster suggested and I must say I like it. It isn't as classic as I initially intended (pure Pascal, nothing classy) but it looks nice and is easy to read and maintain.
There are some quirks. For example, IMO this looks a bit odd:
So it forces me to add methods to the records:Code:var AnimationInfo: TmngAnimationInfo; { A record. } Animation: TmngAnimation; { Another record. } begin ... { Gets animation information. } mngAnimation.Assign (Animation, AnimationInfo) ... end;
I think I can live with it, specially because the disk access (including an IFF implementation) is done by thread classes.Code:var AnimationInfo: TmngAnimationInfo; { A record. } Animation: TmngAnimation; { Another record. } begin ... { Gets animation information. } Animation.Assign (AnimationInfo) ... end;
I'm also wondering if type declarations should be inside the static classes like:
Anyway there are a few functions and procedures I'll keep outside the static classes (for example, the mngInitialize function that initializes the engine).Code:var AnimationInfo: mngAnimation.TAnimationInfo; { A record. } Animation: mngAnimation.TAnimation; { Another record. } begin ... { Gets animation information. } Animation.Assign (AnimationInfo) ... end;
No signature provided yet.
Bookmarks