[coldbox:4197] Jumping in Face First -- n00b

Hello all,

I recently started a refreshing new position in where instead of
having to clean up a lot of old spaghetti code, I can get started with
new development and using a framework. Over the past few months, when
I had time, I have tried to pick up other frameworks just to apply
them and get used to using them.

After doing a good amount of research, I have decided that CB is going
to be the framework to use to develop our applications. Great. So, now
here I am in a pit of documentation (which is excellent by the way),
but the serious desire to get to coding and learning this great
framework.

The problem is, I have a lot of CF experience but I have never really
had the best opportunity to jump aboard the cfc(OO) train. Most jobs I
had were the "please fix this app as fast as you can and no we can't
rewrite it" type of jobs. However, now that I have this opportunity I
want to do things right.

I'm doing my best to get up to speed on the framework and to
incorporate it into our site. One of the first tasks that I have is to
create a huge, and I mean giant, form, collect the data and save it to
the database. Of course, with this task there will also be reading of
the data, updating the data etc.

My first thought is this:

I have read as many tutorials that I can find on CB and I have created
a view called pdfForm.cfm which the entire form will live. Since the
form is so large I wanted to validate it with cfform so I know the
data will be correct before I go ahead and submit it.

Again, I am trying to do this the right way and not write procedural
code in a MVC framework (if such a thing is possible). I wanted to
pass this to the list as I will be building the form first. I will be
writing my first cfc to handle the data after I have the form setup
but I wanted to make sure I am heading in the right direction before I
get too far into it.

Thanks in advance for any suggestions, or any comments.
If you know of any other resources or anything that you think would be
good reading, please suggest it.

Thanks,

Mal

Hi Mal.

This is just my opinion/preference, but I personally despise using CFFORM; to me, it just forces you to live inside a small, very special box that I very often find to be too confining. I can see that your purpose in using it is to be able to do client side validation, and there are several alternatives to CFFORM that will allow you to address that concern WITHOUT being painted into a corner. My personal favorite is a little JS library called TMT Validator; very easy to implement, very extensible, and for the most part doesn’t even require a lot of Javascript knowledge as it is implemented in much the same way as CFFORM… tag attributes. There’s also a library i’ve heard about called ValidateThis (don’t know anything more about it), and if you fancy learning some JQuery or Prototype (which I highly recommend!), you can implement validation with those as well.

That being said, I would not rely strictly on client side validation to ensure that proper data gets submitted to the framework, but also write in code on the backend to validate what has been submitted before attempting to process it.

As far as your own personal OO journey, I was where you are about 5 years ago; strictly procedural background, didn’t see the real need for using CFCs, had no clue what a framework was; What I can tell you is that I know for a FACT that it is not an impossible hill to climb, and that if you bang your head against a thing long enough, it WILL get inside! :slight_smile: I can also tell you that traversing this learning curve is much more than just “professional improvement”; I’m convinced that in a very short time if a CF developer doesn’t have a lot of the OO concepts down and using them regularly, that they will be hard pressed to successfully compete in the job market.

Coldbox in particular is an extremely robust tool set/framework that can be a bit overwhelming at first glance due to its sheer breadth of functionality. But don’t fret it, there is no need or reason to learn all of it at once. Learning CB or any other OO concept is a layered approach, so focus first on those core ideas and concepts and, as those become well understood and second nature, then begin adding on the next layer. Be aware, too, that as you learn, you will be revisiting code you wrote just a week or a day before; don’t let that be a source of frustration though, just accept it as a sign of your own progress. :slight_smile: One of my own “problems” that I wrestle with is wanting to understand the whole enchilada before I write a line of code; but you have to battle against that urge or you’ll find yourself frozen in time and never completing anything. Just write as you go using what you do know, and plan on revisiting portions later when your knowledge increases.

There are a lot of CB tutorials out there, blog posts, the documentation is outstanding, and I can’t say that there is any one single starting point that is the end all place to begin in learning it. Just keep on doing what you’re doing, browsing docs, dissecting sample apps, doing your own experimentation, and when you’re stumped on something or need input, using the community as a sounding board or resource. Though each of our OO journey’s is our own, we are still all in this together!

Oh, and don’t forget the fact that formal training is available, if you can get your employer to spring for it. I attended a few months ago and I can’t tell you how invaluable it was to helping me grow in my understanding of CB as well as some core OO concepts.

Going to CFUnited this year? :slight_smile: Lots of OO wealth to be shared there.

Doug Boude

Did you look at the sample applications?

Don't read too much....the best way of learning is just start coding

Ernst

Doug,

Man that was inspiring!! How about writing a blog post on the coldbox blog about this, especialy this paragraph:

Coldbox in particular is an extremely robust tool set/framework that can be a bit overwhelming at first glance due to its sheer breadth of functionality. But don’t fret it, there is no need or reason to learn all of it at once. Learning CB or any other OO concept is a layered approach, so focus first on those core ideas and concepts and, as those become well understood and second nature, then begin adding on the next layer. Be aware, too, that as you learn, you will be revisiting code you wrote just a week or a day before; don’t let that be a source of frustration though, just accept it as a sign of your own progress. :slight_smile: One of my own “problems” that I wrestle with is wanting to understand the whole enchilada before I write a line of code; but you have to battle against that urge or you’ll find yourself frozen in time and never completing anything. Just write as you go using what you do know, and plan on revisiting portions later when your knowledge increases.

AWESOME!!

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Doug,

Thanks for your reply. I will look into your suggestions that you mentioned. I guess at this point I wanted to make sure I have the framework down and not chance throwing some other technology in the mix in case I get errors. This OO journey is a long and slow one for me. It’s just how the jobs have been coming but having this opportunity I am going to make the most of it. Be sure to expect lots of posts from me very soon.

Luis, I have picked up a copy of your book on CB and I’m diving right in. I also agree that jumping in without “knowing” everything will help me learn faster.

I am hoping to attend CF Objective this year. It makes more sense than anything since I live less that 10 miles from the event. I asked my employer last year and they didn’t see the “value” in having a developer attend. This year, I am hoping that my new company will let me attend. It may take some convincing to let the new developer they just hired attend a conference when I will have been here for less than 6 months. This is why I will be working hard to complete some of the smaller tasks they have assigned so that I can make a case.

Thanks,

Please keep the suggestions coming.

-Mal

PS: Yes, I’ll be asking to attend the CB training if I can get them to pay for it! :slight_smile:

FWIW, I was in your shoes not too long ago as well. I tried reading a
bunch of resources about OO methodology, absorbing some, not
understanding others, then tried to work on diving in and getting some
stuff done. One of the big problems from the perspective of a new
learner is that there is no single "right way". It is kind of like
learning Calculus that way. Up through Integration, people are used to
learning a method for a type of problem then just using that method to
solve those problems. With OO, there are some general principles about
what you are trying to accomplish, but no hard and fast rules about
how to do it. That can make it difficult to synthesize the information
and examples you find on a bunch of different blogs because there are
so many styles encompassing them. I found this frustrating at first,
but the key is to remember that there is no "one true way", there are
better ways and less better ways and a lot of times it depends on what
you are writing.

A couple things to remember: Refactoring is your friend. I have my
first big Coldbox/MVC/OO app out in the world now and I've gone back
to make 2 reasonable sized sets of changes. When I did, I went in and
looked at where I had duplicated code or made weird decisions and set
aside a day to clean some of that up. I made some less than stellar
choices because I was new but the code worked, which is the important
part, and was in a framework where I could more easily refactor things
to make it cleaner and more obvious. That's how it is supposed to
work. And there were some parts where I was tickled pink because new
requirements came through and I found that I had methods written to do
exactly what I needed because that functionality was in another spot
in my app as well. Code reuse! And I found that I was able to change
one method to incorporate this new service we had instead of doing it
all myself as I had in the beginning and I didn't have to change any
of my handlers or service layer. Encapsulation! So some things worked
just the way I had hoped and others, not so much. The next project,
hopefully it is better.

Don't try and tackle everything at once. At first, I was going to try
Coldbox and IOC and ORM and Unit Testing and make the all singing, all
dancing light of the world app. It was confusing. So I scaled back and
started with CB and added in some autowiring of my objects and
services and left it at that. Then on a subsequent project, I wrote my
first interceptor. Now on my new project, I'm adding in ORM and Unit
Testing. My first apps won't be as elegant as my new one, but that is
to be expected and there will be opportunities to refactor in the
future (see above point).

Overall, I'd start small and build your way up. Don't get too caught
up in the beginning about OO-fights (like the DAO/Gateway/Service
pattern versus just DAO and Service). Look through the samples that
come with CB, pick a couple of blogs with examples whose style seems
to work for you and start building some stuff. It won't be optimal and
a year from now you wont' be doing it the same way, most likely. But
hopefully you'll still be doing it a year from now and with a much
greater understanding.

Cheers,
Judah

All good points. And I think this is what is best for me. I am on my way to writing this app. Of course I see potholes ahead. But, this is all part of the learning process. I do apprecaite every word of encouragement and reflection.