Qt's Home

The Story of a french guy discovering the world

Week 5 - Day 3 - Ajax, MVC and Congratulations

| Comments

Ajax

What is Ajax?

Well… It is not a cleaning product), or a football team. Ajax, or more A.J.A.X. stands for Asynchronous Javascript And XML. Wikipedia)

Javascript is a very well known scripting language used widely on the internet nowadays (I would say on webpages, but the use is even wider than that). XML is a markup language that looks a lot like HTML (One could even say like two brothers –hint– with the same parents –hint–…). Basically, it is supposed to be a way to stock data between tags that look like : < stuff >This is stuff< /stuff >.

In short, what AJAX is is a link between the Javascipt (= the language that makes stuff display dynamically in your page) interact with stuff, using XML (at first, now that part changed), and then giving you info back, without disrupting the lifecycle of your page viewing.

When you get on Facebook and get to the bottom of the page, you know how it loads the rest? AJAX. Javascript sends a request, get data, adds it in your browser. You don’t reload, JS does this refreshing for you, and replaces what needs to be replaced.

If you’re looking for more examples : You load Buzzfeed, and only the first image loads first: AJAX. You read twitter and it shows you a new tweet on top when one appears: AJAX. You register on any site that is less than 10 years old and it just shows a “You have been registered”: AJAX.

Let’s just say it is used everywhere nowadays, more of less, to enable the “one-page” web-browsing habits you got used to.

And that is what we did yesterday. The idea, in more technical terms, is that your javascript (or JQuery) sends the same request that you were sending from a link, or a button (POST, GET, etc… RESTful routes), and treat that data. It can redirect if need be, or just print that new alert, tweet, post, or even just do nothing even though the server got all the info you sent (Bad practice guys… stop doing that, please)

We did it with simple exercises but that was part of the things that I did not know about. Now I do, and I love it. Expect some nice projects with that when I get some time!

MVC

MVC stands for Model-View-Controller (And yes, today is acronyms day in Quentin’s world).

It is part of the “Software design patterns”. If you don’t know about design patterns and you are a developer, please be ashamed of yourself.

Design patterns) are a funny and important topic. The idea is that at some point, people realized that no matter the language, the scope of the problems, the kind of apps, etc… The problems developers were facing could very often fit in one of a very few number of cases. And once they had a solution for a problem, they could actually re use that same solution for every one of the problems they had later that had similar traits with the one they just solved.

So from that, they built “patterns”, saying : When you have Problem 1, it can be solved with Solution 1. The problem is not necessarily clearly defined and may very well be more widely defined than what they thought about, just like the solution is very often quite hard to understand, maybe even more than the problem itself. Yet, Problem 1 will always be solved by Solution 1. You can make something up, but in the end you’ll just redefine Solution 1.

Think about it this way : Some people one day invented wheel (Great example). We changed the kind of wheels we used, the materials we used, and we even made stuff that remotely look like wheels but are not really, will never roll and all that.
But in the end, where you need something that can help things turn, an object that supports other things and enable it to move, you make a wheel. If you try to make it another way, it’ll not really fit until you make a wheel. Maybe one day somebody will find a great counterargument for the wheel. Yet, that solution seems to be pretty useful, we’ve been using it for millenias after all.

Design patterns are like wheels of your program. You use them, and you don’t have to search for what is the best solution to support your object and make it move easily, you don’t reinvent the wheel every time you want to do that (Yes, I used that example for that ‘pun’).

If you develop, you should learn about and start using them. You will be asked about them, they will be an insight on your proficiency, and using them will save you a great lot of time.

Among these Design Patterns, MVC is an architectural decision where you decide that instead of putting everything together, you’re gonna split things up :
Models : They are your object. They know their states, and they can change/add/return theses states. A tree has branch, but a tree does not cut itself. It can just … be, and have characteristics.
Views : What you are going to show that user. Are you going to print stuff to the console? Print in the page? Play that in Gifs? It only knows about itself, and you tell the ‘view’ to ‘Show the menu’, or ‘Give the answer’ and give it an answer to show. – Controllers : The core. It has Models and views, and makes things happen between them. It is where you logic should be.

If I have time I’ll get you some example of that made by a new boot. She really defined it the way it should, and if you need an example, that will be it ^.^

Congratulations

I can’t be speaking only about coding. The header says “A frenchman discovering the world”, not “A coder coding code”.

So today, I’ll just say that yesterday, I got my first congratulations for the work I have accomplished. And that is a big deal for me.

For those who don’t know me, I am in DevBootcamp not to graduate… But to ACE it. I am here to show the world that I CAN do it. That is what I came for. That is what I work my ass for and I will keep on doing that.

I want to be the proof for everybody I can that, no matter what you’re told (I was told when I was a kid that I may just not live up to 20, I was told that I needed a diploma, I was told a lot of things), no matter what happens, what people think of you, you can be what you want to.

I have always believed that one could be what he wanted to be if he poured his heart into it (Too much disney, some may say), even though some times and/or places may have been pressuring hard on that belief, but now I want to be the living proof that this is true.

And if you feel like this is far from the truth…

Watch me.

Comments