New templates for Ajax/Rest/JSON, etc

Posts   
 
    
trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 15-May-2009 21:28:53   

I've recently been trying to get into doing more client side web stuff using Ajax/Rest/JSON etc, whatever the popular words of the day are for this...please excuse any improper terminology use, hopefully you can catch my meaning.

I have been doing quite a bit of reading and it seems there are so many different ways to do this (even more so than with other technologies or concepts). And for someone that is not very skilled in web development in general, it is quite intimidating.

I searched around a bit on the forums here and found some relevant posts, such as: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=14336&HighLight=1

But I'd like to ask Frans, have you considered writing a set of templates that would enable some default base RESTful functionality for an LLB project? I am thinking somewhat along the lines of templates that would generate the appropriate web services for basic CRUD operations, as well as the accompanying client side javascript (jQuery preferably) that could be used to call the web services. Without thinking about it too much, I would think that a standard javascript library could be generated that could be called directly from html pages, which would then call right into the generated web services.

I can also think of many cases where the default generation wouldn't work, in this case we would have to hand code most or all of it (the generated libraries would be a useful good starting point).

So, from what little I know, I can see some issues that would arise with this, but it seems to me that there is a serious architectural paradigm change happening now. Everything seems to be moving towards this loosely coupled and loosely typed architecture. There is much i don't like about it, but at the same time, you are gaining quite a lot in exchange for what you are giving up.

So I'm just wondering Frans, if you have put any thought into this? It seems to me that this could really turn into a large, very complicated addition to LLBLGen if you put a whole bunch of thought into doing it "properly" (as much as you have put into LLBLGen itself). however, it seems to me that properly has much less meaning in this new world....considering you are pretty on top of things in general, I bet I would be pretty happy with whatever you decide is a decent way to do this.

I would love to hear yours (or anyone else's) thoughts.

trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 26-May-2009 20:12:36   

Relevant article....I think you could step up and fill this gap quite nicely with a few nice templates and a nice little sample application for learning MVC. The attention this would bring to LLBLGen I think would be HUGE!!!

http://www.kevinwilliampang.com/post/What-ASPNET-MVC-Can-Learn-From-Ruby-on-Rails.aspx

trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 27-May-2009 22:38:40   

Frans, any comment on this at all?

Even "ain't gonna happen" would be better than nothing! simple_smile

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 28-May-2009 02:23:25   

I guess I don't see the point of such a thing. Out of the box with ASP.NET MVC you can build something useful in about an hour using LLBLGen. The key is leveraging the built in IDE tools VS already has. I would be happy to build some templates if you could describe a bit better what you are after.

trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 28-May-2009 21:42:25   

Thanks for the reply....

I think part of the problem is I haven't bitten the bullet and learned asp.net MVC yet...but even then I think there is a lot of hand coding one must do that could be incorporated into a template.

My goal is essentially this (for example): I want to be able to write a UserDetails form (Name, Address, etc), then press the Save button and have that persisted to the database via an ajax call.

Now there are likely any number of ways to do this (of which I know precisely none). My suggestion was for a template implementing "a" methodology or pattern for doing this that works "good enough".

Some complications: - I may not have all of the columns from the User table on the form, so it would be preferable to make my call passing in just the subset displayed on the form (obviously I have to pass in the primary key column values). Because of this, I think UI portion of these templates would have to generate into a temp folder, and one would have to then copy/paste/modify the snippets to support the specific UI implementation. The server side of the template output would not be manually modified, and could somehow handle a subset of values coming in. - I would also like to have a decent client side two way binding system, that supports intellisense

Now, I don't know if this "should", or "has to" be done in an MVC framework, or if it can be implemented or called via webforms.

I don't know the correct answer to this by any means. I also don't know many of the complexities involved in properly implementing a rich domain model / data tier. But because of LLBLGen, I don't have to.

What I'm trying to say is that if a Ajaxy "framework", implemented through a set of LLB templates could be developed for the UI side, it would (to me at least) be as useful as the existing templates have been on the backend. I think I am looking for something somewhat similar to what one gets out of the box with Ruby on Rails (although I have only seen some sample videos of that, I am no expert).

Note: I hope it came through but if not, I will explicitly state here that I am not wanting to generate the entire UI. The ideal is the generation of: - the server side interface - client side stubs for loading the UI as well as persisting the UI back to the server side function. These stubs would manually be copied into a manually coded html form (the first iteration of which may have been generated)....I guess very similar to the existing LLB UI generation templates.

I'm sure there are some gotcha's involved in this, but hopefully I've gotten the general idea across?? Is something like this possible??

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 28-May-2009 21:59:14   

The nice thing about ASP.NET MVC is that what you seek to do through templates is already done in the IDE. If I make a controller action to display a list of books for example. I can right click on the method and generate the scaffolding. When persisting, model-binders automatically populate objects from the Form NameValue Collection. Handling an asynchronous postback can be done in a line of code using JQuery.

trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 28-May-2009 22:07:30   

Thanks Seth.

Well this sounds great....but from reading that article I posted above, I distinctly got the impression that this awesomeness is not done for you. Or, maybe because they are lacking any ORM whatsoever, once you have one, the rest is easy?

The nice thing about ASP.NET MVC is that what you seek to do through templates is already done in the IDE. If I make a controller action to display a list of books for example. I can right click on the method and generate the scaffolding. When persisting, model-binders automatically populate objects from the Form NameValue Collection. Handling an asynchronous postback can be done in a line of code using JQuery.

So, if I understand correctly, via ORM services via LLBLGen, plus manually coding your own controller, the HTML <-> controller communication code is then automatically generated by Visual Studio??

Have you ever happened upon a video that demonstrates someone building an app like this (there are many such videos for Ruby on Rails).

Thanks!

trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 28-May-2009 23:52:40   

I just watched this video: http://www.asp.net/learn/mvc-videos/video-395.aspx

Which, by the way, is based upon the MS Entity Framework. (So, could LLBLGen be swapped in for that and everything else stays the same??)

Interesting. Didn't get to see all the resulting html, but I suspect there is a bit too much Microsoft "magic" going on here for me. For example:

public ActionResult Create([Bind(Exclude="id")]Movie movieToCreate

This makes me wonder how this binding is happening. If it is magic, I don't think I want any part of it.

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 29-May-2009 02:12:01   

Hi Guys,

I'm not so hot on ASP.NET MVC. To me, it's just more of the same. I'm sick of writing DHTML/JavaScript/CSS. I did that years ago. No longer.

You should see some of the stuff we're doing in the Visual WebGui community, the best GUI framework for the web. http://www.visualwebgui.com

Check out this screencast a friend of mine created the other day (Jump to 1:00 or so):

http://www.screencast.com/users/Visualizer/folders/VWG/media/f1756fef-441a-4773-a606-95db561cb7dc

Yes, that is a Drag & drop form designer - all in the browser, built with Visual WebGui. Properties window & all. I'm happy to say I haven't written one line of DHTML/JavaScript/CSS in the past 2 years. Everything is 100% AJAX out of the box. And you can use any ASP.NET controls with Visual WebGui. Everything is straight-up C#/VB.NET, and all your breakpoints hit server-side. I never debug client-side anymore. It's beautiful.

Not only that, but it's probably the fastest AJAX framework out there. VWG is completely stateful. The server-side knows exactly what the client-side's screen looks like; because of this - the server is able to perform a diff function between the server's version & the client's version of the screen - so the server only sends the smallest screen changes down to the client's browser. It's fast.

I've been merging LLBLGen with VWG for 1.5+ years now. It's coming along well. I hope to share my findings soon. I'm not far from creating on-the-fly CRUD screens at run-time.

Ryan

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 29-May-2009 04:39:34   

It is not magic. It uses reflection to query the objects properties and then builds the scaffolding. You should know that with code nothing is magic. Because these are objects it is querying, entity objects work just fine out of the box. All one need do is remove the extra entity properties used by the LLBLGen framework. I did a demo of this using the pubs database a week ago for the staff at work. Additionally, if the "magic" model binding is not suitable, the framework allows you to create custom model binders. Lastly, if people truly get sick of writing DHTML/JavaScript/CSS, then those people are not true web developers. DHTML/JavaScript/CSS is the definition of web development. Anything that goes around this is contravening the way the web is defined and is thus suspect.

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 29-May-2009 05:19:14   

Seth -

No offense, but the web is stuck with old standards. Old standards built on top of old standards. What we have now is what I compare to hacks. You may like them. I do not. Only recently have libraries like jQuery, etc. been able to compile all the hacks together into a single library.

So a Silverlight developer is not a web developer?

Ryan

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 29-May-2009 06:35:04   

Silverlight/Flash etc. again are circumventing the way the web was designed by installing a separate run-time. Everyone went crazy over how Active-X was crap and yet somehow look aside when it comes to Flash/Silverlight. As far as old standards, it is what it is. As far as having to hack our way through web development, yes I agree. But it is not the standards' fault, it is the many different browser's fault. ASP.NET (webforms) is the mother of all hacks. It pretends to be just like windows development with its inane encouragement of sloppy markup (viewstate, postbacks, need I say more?). While I have not looked into the framework you are suggesting should be used, it seems to be more of the same: a way to circumvent the way the web ACTUALLY functions in order to appease a developer who has become "tired" of actually knowing and using DHTML/CSS/JavaScript etc. Whether you like the standards or not, as developers we are stuck with them. Going around them to make OUR job easier is a disservice to our clients and our end-products. (Incidentally, I am not offended because your arguments are cogent, incisive, and, above all, are not personal attacks but observations regarding the topic at hand. If I were to become offended then I would be an idiot - which I am not).

trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 29-May-2009 11:18:11   

Seth: "It is not magic. It uses reflection to query the objects properties and then builds the scaffolding. "

I want to get away from Microsoft helping me at runtime as much as possible. I don't want my binding done via reflection. As I've said, I honestly don't know a whole bunch about these "restful" interfaces, etc. What I want is, I want to see client side javascript, via jQuery, explicitly calling a server side interface and explicitly passing in parameters. Yes, I am also thinking this particular code can initially be code generated, but I for some reason want to see the code. In this case I consider the binding via reflection to be "magic".

This intimate knowledge (somehow) between a controller and a view (maybe I am misinterpreting it) doesn't feel right to me. It feels kinda like MS Access forms programming.

@rdhatch I've heard some good things about visualwebgui. What I didn't like for starters is its licensing costs. Now, I work in a corporate environment and that cost wouldn't bat an eye, but I don't like it. I predict open source libraries like jQuery will suffocate commercial frameworks like that within 3 years. Also, I think the asp.net webforms control suites days are numbered as well for the same reason. I have had nothing but trouble trying to get their advertised ajax functionality to work, and when you call their support line, they have nothing but contempt for their customers who pay literally tens of thousands of dollars per year. You can spend days working through a problem, ultimately determining it is a bug in their controls, and they still won't post it on their forums.

Is visualwebgui different? Maybe. I don't care. I've had it with 3rd party commercial providers that supposedly make your life easy. Increasingly, open source javascript libraries and plug-ins will allow you to do everything they can do, and at the same time, you'll understand what the hell is happening in your code.

So, Seth, am I just destined to be unhappy with asp.net mvc? Or, should I be looking for a way to just bypass this scaffolding framework functionality?

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 29-May-2009 16:32:59   

Notice that I said it uses reflection to build scaffolding. This is NOT at runtime. It builds html for you. It is the job of the developer to go in and clean it up. As far as using Ajax to post back, like I said earlier, it is literally one line of code using JQuery.