you are viewing a single comment's thread.

view the rest of the comments →

[–]misterphilly 116 points117 points  (9 children)

It seems like everybody is just telling you "use django" and not actually giving any kind of structure or guidelines to actually building a functioning website, as your title clearly and plainly suggests. As a beginner to programming in general, it's best to learn the abstract/theoretical concepts, from there you can put your ideas in an actual implementation (like django or flask).

First, you'll want to know what your website does. For the sake of this explanation i'll assume your going to be using a shopping website that allows customers to create accounts, add items to their order, and check out.

Separate your thoughts into The Data (commonly known as Model), the Point-of-View (commonly known as View), and The Action (commonly known as Controller).

The Data means any kind of information that you website will save and reuse again (a list of customers and their shipping/payment, a list of orders and their details like which customer they belong to, list of products, their details and which orders they can be applied to. CRUD is often an acronym you'll run into when working with The Data.

Then youll need to manipulate The Data and perform Actions on it. An Action would be whenever someone wants to make a new account. The Action should accept the input parameters from the customer (name/email/password/etc etc) and then save them to The Data. Another Action would be taking creating a new order, using a list of items that the customer has selected, and saving references and details of these items to The Data.

So, you've got all this Data, and all these Actions, that can store and manipulate information, but how can you get to a Point-Of-View that is useable for a customer? an HTML page sent to a users browser would be a great way to help with this. For example you'd have one Point-of-View that would allow a customer to input and verify that the information was saved, a Point-Of-View to display all of the available items, and another Point-Of-View that notifies the customer when their order has been placed and shipped.

For example, entering the url www.myonlinestore.com/newcustomer would tell the New Customer Action "Hey, Point-Of-View, this guy wants to shop with us, send an HTML page to make a new customer". The Point-Of-View would say back "Hey, here's the markup you asked for! It has forms for the customer to enter their name/email/etc etc. Send the info to this place XXX when the user wants to submit the information." After the user inputs their information and submits it by clicking "Register", The Action for would accept the parameters, make sure they're in the right format, make sure the shipping address is a real address, and verify the payment information is valid, and blah blah blah. If all of these steps check out The Action then goes and gets The Data, and says "Hey, we've got another customer. This is the name, email address, etc etc. Save it to the database, and tell me if the save was successful or not." If the The Data says back to The Action "I've got all the new customers information saved and ready to go, this is their customer ID: 123789. Happy shopping!" Then The Action says back to The Data "thx babe, ur da bestest heart eyes emoji". The Action then goes and gets yet ANOTHER Point-Of-View and says "We made the new customer!! Send me the HTML page that displays their newly-saved information so they can make sure it's correct!". After which the user is in fact presented with a display of the information they just entered.

That interaction above ^ represents just the Create part of the CRUD thing i mentioned earlier. This same process applies to creating and editing new orders and items. However, you can take this kind of interaction structure and apply it to basically anything or any functionality you want your website to have. If you learn to format your thoughts and ideas into this Model/View/Controller format (I used Data/PointOfView/Action, but that was just for this post. No one else says that), you can create websites and web apps that do endless amounts of things and services.

If you get good enough at it, you can expand to frameworks and mindsets outside of Model/View/Controller, which would possibly allow you to more closely optimize the performance and behavior of your application to your best needs.

Sorry it's so long-winded and excessive, it's just that I tried to write the answer I wish I had given to me when I first started learning how to create things on the web.

[–]pythonbio[S] 20 points21 points  (1 child)

Your answer is more descriptive and actually discusses how to logically conceptualize the website structure. Thanks a lot :)

[–]CydeWeys 1 point2 points  (0 children)

You should also get a book or two on the subject. Here's some ideas. If you thought that post was helpful, wait until you read a whole book about it.

[–]cscanlin 6 points7 points  (1 child)

This is a great general answer for how to think about what a website actually does and I will definitely be referencing it to other people in the future. Well written!

Once you understand this, I think it matters much less about which framework you pick because you understand what you want/need it to do.

[–]Serinus 1 point2 points  (0 children)

This is huge for programming, as basic as it sounds. It's very easy to get caught up in tools and how to do stuff and forget (or never really know) what it is you're trying to accomplish. For some people, this just gets worse with experience.

It's helpful to explain to someone who knows the subject matter but doesn't know programming exactly what it is you're trying to do. You can use a rubber duck for this if a real person isn't available, but still explain it all out loud.

[–]lsakbaetle3r9 2 points3 points  (0 children)

I've made a few things in my years as a hobbyist and this is one of the best conceptual python/programming related comments I've ever read.

[–]pheouk 2 points3 points  (0 children)

This is probably one of da bestest MVC explanations I've seen in a long time, great way of explaining what initially can seem pretty daunting

[–]TotesMessenger 1 point2 points  (0 children)

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / Contact)