[coldbox 3.8.0/cf10] - Best Way to Implement Model

Not only am I new to CF, ColdBox, but also brand new to the web development world… so please pardon the ignorant in my questions… Also, time and resources are limited, so from what I’ve learned so far, I think ColdBox would help speed up development once I get used to the framework.

So, I have a challenge ahead of me: to develop a web application with full CRUD functionality and be able to deal with large set of data…in the 4000+. I still don’t have a good grasp on what would be the best method to use in creating the Model. Many terms (ORM, Webservices…etc…) are being tossed around that I have yet to fully understand how they are implemented. I am familiar with Java Data Binding which helps when dealing with many properties in a Bean. Could someone please in a direction of best practices when dealing with large data set? Data are being stored in SQL DB. And also, can this problem be efficiently solved with ColdBox?

Thank you for any pointers.

Forgot to mention “REST”…is this the latest in web development?

Sounds like you also need to get up to speed with ColdFusion first, then you can tackle ColdBox. You are right ColdBox will help you do more work faster, but the learning curve is a little tricky if you don’t have the basics of ColdFusion first.

Data is used in ColdBox via any of the methods ColdFusion use, that means you can use queries or ORM which ever you prefer. Then you just access the data that is needed at the time of the request.

Large sets of data is not the issue nor do you need to concern yourself with that fact either, any language regardless can access what you tell it to access. It is how you access the data that you need to learn…

So, I have a challenge ahead of me: to develop a web application with full CRUD functionality

Sounds pretty standard.

and be able to deal with large set of data…in the 4000+.

4 thousand records really isn’t that many. Wait until you get to millions :slight_smile: As far as interfaces that display, edit, and add records, large recordsets have little bearing on how you write your app other than your list screens. You’ll probably want to paginate the results onto multiple screens with search and filtering capabilities. This has more to do with your database layer than anything else though.

I still don’t have a good grasp on what would be the best method to use in creating the Model.

There is no “best” way, just a lot of opinions :slight_smile: Experiment and find what works best for you.

Many terms (ORM, Webservices…etc…) are being tossed around that I have yet to fully understand how they are implemented.

If you have a Java background, CF ORM is implemented under the hood with Hibernate. CF makes ORM pretty easy. No XML-- just define CFC’s and let CF map them for you to the database tables.
Here’s a preso i did on intro to CF ORM: http://vimeo.com/80159109
Here’s a CF ORM tutorial: http://www.learncfinaweek.com/week1/Intro_to_ORM/
And here’s a preso on how ColdBox-specific tools for dealing with ORM: http://www.coldbox.org/media/cbdw2013#5_1

You don’t have to use ORM though. Many people find it quite helpful, but it may be more confusing for a beginner since it places another layer of abstraction into your application since you won’t work directly with the database.

Web services are simply web-based end points you host on your web servers to expose functionality to a remote system. If your CRUD interface will be used soley via your HTML GUI, this is currently no concern .

I am familiar with Java Data Binding which helps when dealing with many properties in a Bean.

Never heard of that, but after a quick Google it sounds like it’s aimed more at desktop Java apps and not web uses. Correct me if I’m wrong.

Could someone please in a direction of best practices when dealing with large data set?

Paginate your results and put search/filtering controls on the interface. Also, make sure you’re working with a DBA to help monitor DB performance. Probably not that big of a deal with only 4,000 records though.

And also, can this problem be efficiently solved with ColdBox?

Any web-based problem can be solved with ColdBox :slight_smile:

I’d start with a list of wireframes or mockups from your designer regarding what screens you need to build. Then start thinking
about what kind of data operations you need to support for your users. This is your basic service layer.

bean:
widget.init()
widget.setProperty()
widget.getProperty()

Service:
widgetService.newWidget();
widgetService.saveWidget();
widgetService.getWidget();
widgetService.listWidgets();

Now, think about the actual screens/UI you’ll be building. Write up a list of handlers and actions you need to create within ColdBox MVC along with their related views.

/handlers/widget.cfc
-index
-add
-edit
-save

/views/widget/index.cfm
/views/widget/add.cfm
/views/widget/edit.cfm

It may help you to mock up screens first, creating your handlers and views-- but I like to build the services and beans (models) first as it forces me to not be tempted to mix business logic into my handlers.

~Brad

Forgot to mention “REST”…is this the latest in web development?

Not hardly. REST is the oldest in web development. It’s the basic principle that the web is broken up into resources hosted on servers. Each resource has a unique URL that points to it and a client can send HTTP requests to a server, referencing a resource and interact with the resource using different verbs (GET, POST). That’s all just a really fancy-sounding way of describing how your web browser works. The term REST has had a resurgence though lately in regards to web services. REST endpoints lack the complexity and weight of standards like SOAP or even XML-RPC so they have become popular among devs…

For what it’s worth, ColdBox has awesome support for REST APIs with our SES routing, render data utilities, and HTTP verb mappings. I wouldn’t worry about any of that for now though if you’re just building an application for users to use. You would only need an API/Web service if there’s other programmers out there that you want to be able to write third-party apps that interface with your back end to automate data operations.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I stand corrected this morning…that dataset could be up to 700,000+.

Thanks everyone for responding and for your patience in providing guidance…

Andrew, yes you’re right, I’ve been learning ColdFusion as well…

Brad, your information is just what I needed. I was given the impression that in order to have a robust web-based application, then ORM needs/should be used. You’re right, I came from Java desktop application development background, so everything about web-development is new to me. I appreciate you taking the time to provide all the information. I too, tend to build a solid model first…

One more question if you don’t mind… in Java desktop application, GUI fields can be binded to the bean properties and changes are detected via changeListener events. Can this be done similarly in web development? YES, I do have soooo much to learn!! But at this point, I need to just learn what is needed to fullfill an immediate task…so Yes, I tend to jump around a bit on the topic to learn…which is probably not ideal. But we have to do what we need to do right? :slight_smile:

Thank you again for all the helpful resources and suggestions.

-Tuannie

It is possible with some of the MVC JavaScript frameworks such as Angular.js or Backbone.js if connected to a back-end REST API to save off data changes as they are made. Of course you can write your own binding with JavaScript listeners but that would be a fair amount of work.

I’d recommend getting your feet wet by simply writing a form that you submit back to a processing handler to save the data. Then expand on that. In 6 months you’ll know so much more that you’ll want to start over and redo everything you’re building now anyway :slight_smile:

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

The dataset is not an issue not matter how many records are there, the approach is always the same. As Brad suggested you need to look into pagination for viewing data, for example how would you do this in Java! As the process is relativity the same, just the approach is different.

But as with Java, you pull up as few records as you possibly need, no language is different in that scenario.

As for ORM and Queries, there is no real difference in that one is executing straight SQL to the DB, where as the other is proxied via objects and persisted in memory. If you know hibernate in Java, then you will come to grips with CF-ORM very quickly.