[ home / overboard ] [ soy / qa / raid / r ] [ ss / craft ] [ int / pol ] [ a / an / asp / biz / mtv / r9k / tech / v / sude / x ] [ q / news / chive / rules / pass / bans / status ] [ wiki / booru / irc ]

A banner for soyjak.party

/tech/ - Soyence and Technology

Download more RAM for your Mac here
Catalog
Email
Subject
Comment
File
Password (For file deletion.)

File: ClipboardImage.png πŸ“₯︎ (22.32 KB, 700x802) ImgOps

 β„–22965[Quote]

What is the point of seperating things into public and private in programming? If you shouldn't directly access something in a class then just don't do it.

 β„–22986[Quote]

It’s mainly used for enterprise-level positions where you’re dealing with millions of lines of code, so you need to enforce invariants and minimize the chance of introducing bugs.

 β„–22988[Quote]

its more organized, also if you're working with a team and it becomes cumbersome to say 'don't access [x] [y] and [z] because you're not supposed to' for literally everything you make

 β„–23029[Quote]

>>22965 (OP)
Abstraction. It's useful to think about public variables like inputs which a user can use to modify an object, while private variables are variables which the object uses internally which shouldn't be modified outside of the object. Like the other chud said, it makes it easier to explain to other people how to use your object without breaking it.

 β„–23043[Quote]

are you my retarded former dead coworker who I have to maintain all his shitty code after?
he always used COMMON PUBLIC COUNTER VARIABLES WHICH ALL FOR LOOPS IN ALL MODULES OF THAT PROJECT USED
if you can't tell how that is retarded then please don't ever code

 β„–23044[Quote]

>>22965 (OP)
invariants. sometimes you DONT want other people to modify certain values.
imagine a vector (dynamic array) with a pointer and a length. if you modify that length then you could run into undefined behaviour when accessing the pointer. that's why the length (and even the pointer) is PRIVATE. only the PUBLIC methods on that vector can change the length in a SAFE way that mains the INVARIANTS.

 β„–23094[Quote]

>>23044
NTS but this explanation clarifies much
(NTS is a new acronym that means Not That Soicuck and is equivalent to 4chan's NTA for Not That Anon.)

 β„–23101[Quote]

>>23043
how do they manage to loop in ALL modules?

 β„–23103[Quote]

>>23094
marge

 β„–23230[Quote]

>>23101
when a for loop calls a sub, that sub might have another for loop, which uses the exact same public variable as a counter
I mean it's basically like nested loops using the same counter variable, it's retarded, just like my dead coworker
it's all ancient VBA excel macros code btw



[Return][Catalog][Go to top][Post a Reply]
Delete Post [ ]
[ home / overboard ] [ soy / qa / raid / r ] [ ss / craft ] [ int / pol ] [ a / an / asp / biz / mtv / r9k / tech / v / sude / x ] [ q / news / chive / rules / pass / bans / status ] [ wiki / booru / irc ]