Scaffolding
Moderator: General Moderators
Scaffolding
Please share your experience with the ready-made frameworks you've worked with, or the ones you built yourselves.
0. Err, what is scaffolding (in the terms of the framework you've dealt with)
1. What does the scaffolfing code generate?
2. Run-time or is it stored on disk?
3. What is the source data for the scaffolding?
4. What happens afterwards - how do you change something?
0. Err, what is scaffolding (in the terms of the framework you've dealt with)
1. What does the scaffolfing code generate?
2. Run-time or is it stored on disk?
3. What is the source data for the scaffolding?
4. What happens afterwards - how do you change something?
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Scaffolding
You know in Visual C++ where you can select wizards to crank out the boiler plate code (skeleton basics) for you so you don't have to start from ground zero each time? I believe that is the equivelant of scaffolding. Essentially, I understand scaffolding to be a code generator which knocks out some views, models, controllers and a template for basic CRUD operations -- then you can go in modify it to your likings.Err, what is scaffolding (in the terms of the framework you've dealt with)
Probably varies from framework to framework, but I imagine at least the MVC and template components.What does the scaffolfing code generate?
Sounds like both:Run-time or is it stored on disk?
Personally I only bother to hammer out persisted files and from there -- additionally creating other tables if nessecary.http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html wrote:I then instantiated the scaffolding by inserting scaffold :recipe into the RecipeController class. The resulting CRUD controllers and view templates were created on the fly and are not visible for inspection.
Thats a good question, I've never actually used any other scaffolding from another framework -- just borrowed ideas for my own. I mostly follow Data Driven Development (for lack of a better term) approach when programming so what I essentially try an do is specify the DB table and from there generate the CRUD class, basic view and controller from a standard template. I usually have to adjust the view drastically as the fields seldomly match up one to one. Same for the model, the API is never really a true reflection of the DB table -- but it's the files and required classes in place and the basic HTML which saves me a tonne of time.What is the source data for the scaffolding?
Ideally, one day, I will start on a custom scaffold generator where it generates the skeleton from scratch using UML and other diagrams I have scriblled out -- even better would be a system which allowed refactorings after the fact, taking into consideration any code changes which may have been made.
Ummm...usually with an editor or IDE but I suppose you could pray for changes to occur.What happens afterwards - how do you change something?
Anyways, a framework is just the library code which encforces good practices, like separation of conerns, etc. A scaffolding takes the framework and hammers out some basic applicaiton design (actually creating skeleton MVC omponents, templates, database tables, etc) to get you rolling that much quicker.
My hope is that one day, I do most development from the architectural perspective only, clicking and dragging objects around like something in a UML diragram -- click go and test -- only making tweaks when absolutely nessecary.
Cheers
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Scaffolding
I have been thinking about the same questions for the Skeleton framework. The problem is that there is not just one problem solved by the concept of scaffolding. Sometimes you want code generation of a single class, but you also might want to generate MVC triads. You might want something that customized an existing class. You also might want something that gets DESCRIBE information from the database and creates one of many possible use cases from that information (CRUD, Auth, ACL, etc.).
Most system are uni-directional in that they generate code from configuration data or conventions. That can be straight code generation or cached versions that are loaded at run-time (same thing, different spin).
I have been thinking about having the front-end generate a XML representation that a separate builder uses for code generation. The code generator could be more generic -- fed by multiple front-ends. The XML could also be hand built or generated by a custom tool. It could also be read back into any front-end tools, be modified and re-written.
Interested in collaborating?
Most system are uni-directional in that they generate code from configuration data or conventions. That can be straight code generation or cached versions that are loaded at run-time (same thing, different spin).
I have been thinking about having the front-end generate a XML representation that a separate builder uses for code generation. The code generator could be more generic -- fed by multiple front-ends. The XML could also be hand built or generated by a custom tool. It could also be read back into any front-end tools, be modified and re-written.
Interested in collaborating?
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Scaffolding
I think that is where the NexGen technologies will come from -- they'll be void of conditional logic or complex loops and other language constructs which make languages like PHP powerful but complex. It'll be more declarative than imperative, functional, etc.
I look at my own MVC setup and I see I could easily generate the controllers and possibly most of the models and views. I really have no idea what the config file would look like at this moment, but something with enough expressive power to accomplish the above, obviously.
I look at my own MVC setup and I see I could easily generate the controllers and possibly most of the models and views. I really have no idea what the config file would look like at this moment, but something with enough expressive power to accomplish the above, obviously.
Re: Scaffolding
I was hoping to hear experiences with existing frameworks - don't they do some scaffolding?
Here's what I do:
2. Only the sql generator is runtime (it works on additional input, so it can't be too static), everything else is stored.
3. Description of "fields" and relations, they translate to members, sql columns, HTML "widgets".
4. Class overloading, "scaffolded" template files are loaded only if a user-specified is not existing.
Here's what I do:
0., 1. Generation of sql, code (I don't do MVC, but all three functional components are generated), template files.0. Err, what is scaffolding (in the terms of the framework you've dealt with)
1. What does the scaffolfing code generate?
2. Run-time or is it stored on disk?
3. What is the source data for the scaffolding?
4. What happens afterwards - how do you change something?
2. Only the sql generator is runtime (it works on additional input, so it can't be too static), everything else is stored.
3. Description of "fields" and relations, they translate to members, sql columns, HTML "widgets".
4. Class overloading, "scaffolded" template files are loaded only if a user-specified is not existing.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Scaffolding
I guess I am wondering, what is the use case here? It sounds like it is to manage forms. But SQL generation could be done for many other things too.Mordred wrote:0., 1. Generation of sql, code (I don't do MVC, but all three functional components are generated), template files.
2. Only the sql generator is runtime (it works on additional input, so it can't be too static), everything else is stored.
3. Description of "fields" and relations, they translate to members, sql columns, HTML "widgets".
4. Class overloading, "scaffolded" template files are loaded only if a user-specified is not existing.
These are some of the exact issues I am struggling with at the moment. I would like all "Model"-like objects to implement some basic functionality -- essentially the RecordSet pattern. That way it does not matter whether you just return one or more rows from a connection object or TableDataGateway, or get a ActiveRecord or RowDataGateway object from a finder, or get a POPO from a DataMapper. They would all work the same to objects that use them, and they could all provide information about the table/fields as well.
(#10850)
Re: Scaffolding
Couldn't you abstract the datasource, so that you don't have to use XML? That way, one could also base it on currently existing database (be it Mysql, Postgresql or others), or whatever else datasource (ie XMI file). The thing I would probably start with is some descriptor objects/specification objects, which tell the generator what class has to be written and what it's dependencies on other classes would be. Then, I'd start on creating the builder itself, and I'd make sure the outputted code is based on templates.arborint wrote:I have been thinking about having the front-end generate a XML representation that a separate builder uses for code generation. The code generator could be more generic -- fed by multiple front-ends. The XML could also be hand built or generated by a custom tool. It could also be read back into any front-end tools, be modified and re-written.
After that's done, one could write a XmlDescriptorService, which parses a XML file into specified descriptor/specification objects and pass those to the eventual builder and the code will be written. This way, it's trivial to create a MysqlDescriptorService or, better yet a XmiDescriptorService considering most UML designers today can create those files.
Uhm, naming issues I'm afraid. I'm not familiar with the RecordSet pattern and I can't seem to find it anywhere. Could you elaborate or point me to the right direction? As for what the tool should generate, I'd say POPO objects (if by POPO you mean Plain Ol' PHP Objects) and simple mappers for each POPO. The only problem would be that the generator also has to know how to create the mappers and thus it should know the eventual datasource, yes? I do however think this problem could also be solved by "simple" abstraction.arborint wrote:These are some of the exact issues I am struggling with at the moment. I would like all "Model"-like objects to implement some basic functionality -- essentially the RecordSet pattern. That way it does not matter whether you just return one or more rows from a connection object or TableDataGateway, or get a ActiveRecord or RowDataGateway object from a finder, or get a POPO from a DataMapper. They would all work the same to objects that use them, and they could all provide information about the table/fields as well.
Although you weren't asking me and although I don't have a lot of free time, I would be interested in collaborating with idea's and - if time permits - some code. That is, if you'll have themarborint wrote:Interested in collaborating?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Scaffolding
Sounds like you are well past my limited thoughts about this!webaddict wrote:Couldn't you abstract the datasource, so that you don't have to use XML? That way, one could also base it on currently existing database (be it Mysql, Postgresql or others), or whatever else datasource (ie XMI file). The thing I would probably start with is some descriptor objects/specification objects, which tell the generator what class has to be written and what it's dependencies on other classes would be. Then, I'd start on creating the builder itself, and I'd make sure the outputted code is based on templates.
After that's done, one could write a XmlDescriptorService, which parses a XML file into specified descriptor/specification objects and pass those to the eventual builder and the code will be written. This way, it's trivial to create a MysqlDescriptorService or, better yet a XmiDescriptorService considering most UML designers today can create those files.
http://www.martinfowler.com/eaaCatalog/recordSet.htmlwebaddict wrote:Uhm, naming issues I'm afraid. I'm not familiar with the RecordSet pattern and I can't seem to find it anywhere. Could you elaborate or point me to the right direction? As for what the tool should generate, I'd say POPO objects (if by POPO you mean Plain Ol' PHP Objects) and simple mappers for each POPO. The only problem would be that the generator also has to know how to create the mappers and thus it should know the eventual datasource, yes? I do however think this problem could also be solved by "simple" abstraction.
I agree and it is that abstraction (probably not so simple) that I am looking for.
We it was to Mordred and the Universe.webaddict wrote:Although you weren't asking me and although I don't have a lot of free time, I would be interested in collaborating with idea's and - if time permits - some code. That is, if you'll have them
(#10850)
Re: Scaffolding
Heh, I forgot about this thread.
I have set up the scaffolding in such a way that regenerating stuff will not overwrite "custom" code. During development, I actually regenerate all scaffolding on every request. In that way I can alter the scaffolding code (which is still WIP) AND alter the application code.
As for what the models do, my models have methods for CRUD and consistency checks for the current object, and static methods for working with many model objects (read/delete many by key, count). I guess it's all those patterns rolled into a single class
I support models which can span several joined tables, or which contain arrays of model objects of another related model class, so these methods are generally quite non-trivial.
The use case is to produce as full application as possible from a detailed description of objects' fields and relations.arborint wrote:I guess I am wondering, what is the use case here? It sounds like it is to manage forms. But SQL generation could be done for many other things too.
These are some of the exact issues I am struggling with at the moment. I would like all "Model"-like objects to implement some basic functionality -- essentially the RecordSet pattern. That way it does not matter whether you just return one or more rows from a connection object or TableDataGateway, or get a ActiveRecord or RowDataGateway object from a finder, or get a POPO from a DataMapper. They would all work the same to objects that use them, and they could all provide information about the table/fields as well.
I have set up the scaffolding in such a way that regenerating stuff will not overwrite "custom" code. During development, I actually regenerate all scaffolding on every request. In that way I can alter the scaffolding code (which is still WIP) AND alter the application code.
As for what the models do, my models have methods for CRUD and consistency checks for the current object, and static methods for working with many model objects (read/delete many by key, count). I guess it's all those patterns rolled into a single class
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: Scaffolding
Rails does scaffolding, and it's a neat starting point. That being said it's hardly a replacement for real templates.
In reality, it's only useful for 2 things: impressing clients, and giving you an easy way to populate some data.
I can't really say it's all that useful to be honest.
In reality, it's only useful for 2 things: impressing clients, and giving you an easy way to populate some data.
I can't really say it's all that useful to be honest.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Scaffolding
True dat...Kieran Huggins wrote:I can't really say it's all that useful to be honest.
(#10850)
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Scaffolding
Perhaps we should simplify the process to only create the neccesary files, with the default object notation.
I.e, simply created
User enters "/scafforld/create/user"
If that process was satisfied, I would be just as happy 
I.e, simply created
User enters "/scafforld/create/user"
Code: Select all
class UserController extends A_Controller_Action { }
class UserModel extends A_Model { }
class UserView extends A_View { }
class UserTemplate extends A_Template { }