Home » U++ Library support » U++ MT-multithreading and servers » Skylark OO (reposted from PM)
Skylark OO (reposted from PM) [message #39717] |
Sat, 20 April 2013 14:37  |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
Hello Mirek,
Do you have any plans to make Skylark object orientated? And maybe using MVC?
If you know CakePHP, object orientated in that direction, using components, elements, helpers, etc.
I've tried something in that direction, but i've hit procedural design of skylark.
#define SKYLARK_C(klass, method, path)\
INITBLOCK {\
klass obj;\
UPP::RegisterHandler(callback(&obj, &klass::method), #klass"_"#method, path);\
}
SKYLARK_C(Test, test, "")
SKYLARK_C(Test, user, "user")
That works, but has the requirement to have Http& as parameter to each class method. Another problem is when trying to route to same method (i.e SKYLARK_C(Test, user, "super/user") ). I think id should not be tied with route and object (or function), i should find another solution and allow different routes to same method. Current implementation doesn't allow that too, but would be possible to create a new function which share code.
IMO Skylark is too procedural, loosing what language has to offer . Maybe it was designed for file to be considered as object and SKYLARK() as it's methods?
Example:
// User.icpp
// shared code here
int something = 10;
void doSomething() {}
// end shared code
SKYLARK(UserLogin, "user/login")
{
doSomething();
// and something else
}
SKYLARK(UserLogout", "user/logout")
{
doSomething();
}
I'm wondering where should i put the code to know if user is authenticated and if some method is allowed for current user. Should that be in each method?
In an OO design, class would have virtual method beforeAction (or some other name) which would make possible to skip processing of code if it would return false, or maybe call some other method of class, and call view render earlier.
I would like to use skylark, but right now i don't see it as being practical.
Also there are problems when javascript code is inlined in template. I.e.:
<script type="text/javascript">
$("#test").button();
</script>
get converted to
<script type="text/javascript">
#test.button();
</script>
Should i escape it somehow?
Best regards,
Andrei
|
|
|
Re: Skylark OO (reposted from PM) [message #39718 is a reply to message #39717] |
Sat, 20 April 2013 14:52  |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
mirek wrote on Sat, 20 April 2013 08:37 | Hello Mirek,
Do you have any plans to make Skylark object orientated? And maybe using MVC?
If you know CakePHP, object orientated in that direction, using components, elements, helpers, etc.
I've tried something in that direction, but i've hit procedural design of skylark.
#define SKYLARK_C(klass, method, path)\
INITBLOCK {\
klass obj;\
UPP::RegisterHandler(callback(&obj, &klass::method), #klass"_"#method, path);\
}
SKYLARK_C(Test, test, "")
SKYLARK_C(Test, user, "user")
|
Have you checked chapter 12 of skylark tutorial? That is as far as I got...
One note from my perspective w.r.t. OO with web applications: You have to consider that the application can be running "distributed" over many server nodes, which means that using memory for the storage of object data is impossible (in general case). So it is unlikely that you could directly use C++ objects and somehow make them work in web..
Quote: |
Also there are problems when javascript code is inlined in template. I.e.:
<script type="text/javascript">
$("#test").button();
</script>
get converted to
<script type="text/javascript">
#test.button();
</script>
Should i escape it somehow?
Best regards,
Andrei
|
"$$"
Mirek
|
|
|
Goto Forum:
Current Time: Fri May 09 15:53:19 CEST 2025
Total time taken to generate the page: 0.02645 seconds
|