Skip to content

u/thespite

In this archive from Jun 2010 to Jun 2023

0
posts
10
comments
0
media
932
score

Top comments

MVC is a pattern, and as such it usually "clicks", like you say, when you've fought your way again and again through a specific problem that this pattern adresses. If you've never had problems having data, business logic and chunks of HTML all over your script, then probably you don't see any clear advantage by using MVC.

OOP, on the other hand, it's a complete programming paradigm, which you should really look into. Two very basic and useful concepts are encapsulation and inheritance. I am being non-technical now, because I think that there's a lot of CS-lingo when reading about these topics.

Encapsulation allows you to define properties that define something that you want to work with, and functions to do that work.

Procedurally, you would have variables such as personName, personAge, personAddress, personPostalCode, etc., and a function sendSnailMail with several parameters.

With an OO approach, you would have a person object, with name, age, and address as properties that define a person. Address itself would be another object, with members like street, number, and postal code. The person definition (that's what a class is) also has a sendSnailMail method that already knows what data to use, since it's "inside" the person (thus the encapsulation).

Inheritance is a way of creating things out of person (like man or woman, if you add gender as a property).

EDIT: Text looks way longer than what one can see when typing in the reply box :P

17 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.