<- 1  -   of 3455 ->
^^
vv
List results:
Search options:
Use \ before commas in usernames
lmao. everyone has these days I think. You're doing home office again? What happened with that project where you had to work with that insane lady?
Finished reading the book on ruby and the jekyll docs. It's a pretty powerful tool and apparently lets me do all the stuff I planned for my site. Looks likere there's no need to waste time on my own static site generator.

Wish I had the time to get to building. Getting a new carpet and desk this weekend so I'll be busy with that.
Only part I'm not so passionate about is rewriting my javascript script that opens images full-size in modals. Fuck I hate javascript and the dom.
I like turtles.
Anyone know a good way of explaining why encapsulation is important in OOP? Learning C# and the purpose of making something "private" eludes me. :\
It's only important in certain circumstances. E.g. when you're working on a functionality to be implemented by other people in their programs, on a project with multiple people or a project of a scale where you have to assume that you won't be able to memorize all the details during development.

Imagine you have a class that handles data in a certain way that you want others to use. Your class does some super complicated shit internally and you don't want others to have to deal with that code ever, so you make all the variables that only work internally private so people don't accidentally break your program.
red chamber dream
i find it's also useful in helping you stay organized and understand what code does what. also makes testing easier - you just need to test that public functions do what you want them to do. then you don't need to test your private functions, just the public functions that call them
I like turtles.
Quote from ryu:
It's only important in certain circumstances. E.g. when you're working on a functionality to be implemented by other people in their programs, on a project with multiple people or a project of a scale where you have to assume that you won't be able to memorize all the details during development.

Imagine you have a class that handles data in a certain way that you want others to use. Your class does some super complicated shit internally and you don't want others to have to deal with that code ever, so you make all the variables that only work internally private so people don't accidentally break your program.

So like, more for APIs and such? That makes a bit more sense, I guess my mindset is more that I program self-contained apps or games or whatever.

Quote from arkarian:
i find it's also useful in helping you stay organized and understand what code does what. also makes testing easier - you just need to test that public functions do what you want them to do. then you don't need to test your private functions, just the public functions that call them

But do you not have to test that private functions work correctly as well?
Edit history:
arkarian: 2017-04-07 04:21:17 pm
red chamber dream
you are testing them by testing all functions that call them

basically you can think of your class as a black box. you don't care about what it does internally, only that it produces the expected output when another class interacts with it (by calling one of its public functions)
I like turtles.
But then with the same analogy wouldn't it be easier to diagnose problems with the box by making it completely transparent?

(I'm being a little pedantic but also I genuinely am asking)

I think I have as much understanding of the purpose of private vs. public objects/methods as I did for loops when those were first introduced to me back in college. Which is to say, I allllmost wrap my head around but not enough to apply it in any meaningful way. What is encouraging is that at least loops "clicked" for me a couple years later no problem so hopefully this will eventually too.
red chamber dream
no. then you'd have to write tests for every function, instead of just your public functions
I like turtles.
So... I don't need to verify that my code works if I just put "private" in front of it?
red chamber dream
you have to do what makes sense. private functions should contain logic that only needs to be called by other class functions

as an example, say you have a public function that tells you what time it is. THAT function might, for example, call a private function that does some timezone translation. then you could just test the public function and check that it returns the time in the timezone you expect. you're testing the functionality of your private function indirectly by verifying the public function returns the right value

this does take some time to wrap your head around. it's more of a mindset than anything
red chamber dream
tbh like ryu said, if you're just working on a small personal project, it doesn't really matter much
Edit history:
Turtle: 2017-04-07 08:54:47 pm
I like turtles.
Yeah I'm sure I'll get my head around it eventually, just never fun to only not get one aspect of something that you've otherwise been able to grasp okay.

Probably overthinking it at this point anyway.
turtle yeah I always saw the big gain of object oriented programming to be that of organisation, particularly in collaborative situations where people don't need to understand how other people's code works internally, just how it interfaces externally with their own part of the project. there are also certain things like GUI window toolkits that I think you'd have a hard time putting together without OO.

that said, not everyone thinks it's a good thing. linus torvalds has had a few rants over the years about how abstracting away implementational details in languages like C++ just leads to badly written software that runs slowly because code tends to be written in ignorance of the workings of the other code it makes use of.

(disclosure: I never actually bothered learning C++ and still use plain C for everything)
red chamber dream
stuff like this is why i kind of hate programming lol

i mean i do it for a living, but i don't enjoy it at all
red chamber dream
it's just a bunch of people trying to get everyone else to agree with them
lol yes

it's why linux has like 20 different projects for any one job you might want to do, none of which works properly
red chamber dream
lol yeah and like if i were to write a project, say gamelogs, i would just make every function public and not fucking care about that shit because i know exactly how everything works

but when you have to work with other people, you have to write stuff completely differently
red chamber dream
i don't get the weirdos who write personal projects exactly like they write code for work

like wtf
yeah there's always a kind of level-of-formality target I have for any project I start
I like turtles.
Okay yeah, then for apps I'm just making myself in my own spare time it doesn't actually matter that much. Or that's the sense I'm getting anyway the more I read up on it.
red chamber dream
yeah i mean in general good programming advice is to not worry about doing something more complicated than what you're already doing, unless you need to
red chamber dream
(the hard part is figuring out when you need to change what you're doing)
I like turtles.
Sunk cost fallacy is in full force for sure.