Click here to Skip to main content
15,901,035 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
OriginalGriff30-Oct-18 3:48
mveOriginalGriff30-Oct-18 3:48 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
DRHuff30-Oct-18 4:02
DRHuff30-Oct-18 4:02 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
RickZeeland30-Oct-18 8:02
mveRickZeeland30-Oct-18 8:02 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
W Balboos, GHB30-Oct-18 5:56
W Balboos, GHB30-Oct-18 5:56 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
W Balboos, GHB30-Oct-18 6:34
W Balboos, GHB30-Oct-18 6:34 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
glennPattonWork330-Oct-18 7:09
professionalglennPattonWork330-Oct-18 7:09 
GeneralRe: It's Halloween...Now why is Bob dressed as a Ghost? Pin
Peter_in_278030-Oct-18 15:30
professionalPeter_in_278030-Oct-18 15:30 
GeneralAnother code for thought: public members Pin
Super Lloyd30-Oct-18 0:05
Super Lloyd30-Oct-18 0:05 
As I am starting working again on my home project... I sometimes review and rewrite some old class I use. The general theme of most of my rewrite, if not all, is less. Less lines of code, less methods, less parameters....

Now I put that in perspective with how I like to write code and how it impact my coworkers. I like to make as many members of my classes as public.
Why not? That gives everyone more control over my objects at no cost...

But, on the other hand, make my object more complicated to use, I now realise. What are all those public members for, they might wonder? While staring at an object they might need to use...

While, if I make as many members as possible private, that make my object artificial contrived to used (to my eyes at least) but also excessively simple (look this object only has 1 method and 2 readonly properties!)

Remark this post has been brought to you by: Work colleagues complaining about all my public methods and properties. Make them private they say.

What are your thoughts on the topic?

[EDIT] Thanks to your feedback, I found out it's a matter of context
I am too much used to write reusable utility control and library... what the point of a reusable class, say DateTime, if all members are private?

But hey if I am writing things like a MVC Controller, or the DoSomethingFormClass, or DoSomethinService, everything can be private there for all I care. And from now on I should make everything private there by default, so there would be no pointless arguing...

I think I might even go one further and do private utility classes Roll eyes | :rolleyes:
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!


modified 30-Oct-18 7:42am.

GeneralRe: Another code for thought: public members Pin
Eddy Vluggen30-Oct-18 0:52
professionalEddy Vluggen30-Oct-18 0:52 
GeneralRe: Another code for thought: public members Pin
Mike Hankey30-Oct-18 0:52
mveMike Hankey30-Oct-18 0:52 
GeneralRe: Another code for thought: public members Pin
OriginalGriff30-Oct-18 0:58
mveOriginalGriff30-Oct-18 0:58 
GeneralRe: Another code for thought: public members Pin
Nathan Minier30-Oct-18 1:17
professionalNathan Minier30-Oct-18 1:17 
GeneralRe: Another code for thought: public members Pin
CPallini30-Oct-18 1:02
mveCPallini30-Oct-18 1:02 
GeneralRe: Another code for thought: public members Pin
Super Lloyd30-Oct-18 1:21
Super Lloyd30-Oct-18 1:21 
GeneralRe: Another code for thought: public members Pin
CPallini30-Oct-18 1:41
mveCPallini30-Oct-18 1:41 
GeneralRe: Another code for thought: public members Pin
Super Lloyd30-Oct-18 1:53
Super Lloyd30-Oct-18 1:53 
GeneralRe: Another code for thought: public members Pin
Pete O'Hanlon30-Oct-18 1:14
mvePete O'Hanlon30-Oct-18 1:14 
GeneralRe: Another code for thought: public members Pin
Super Lloyd30-Oct-18 1:19
Super Lloyd30-Oct-18 1:19 
GeneralRe: Another code for thought: public members Pin
Eric Lynch30-Oct-18 2:30
Eric Lynch30-Oct-18 2:30 
GeneralRe: Another code for thought: public members Pin
Marc Clifton30-Oct-18 2:39
mvaMarc Clifton30-Oct-18 2:39 
GeneralRe: Another code for thought: public members Pin
RandyBuchholz30-Oct-18 4:56
RandyBuchholz30-Oct-18 4:56 
GeneralRe: Another code for thought: public members Pin
RandyBuchholz30-Oct-18 4:04
RandyBuchholz30-Oct-18 4:04 
GeneralRe: Another code for thought: public members Pin
David Crow30-Oct-18 4:17
David Crow30-Oct-18 4:17 
GeneralRe: Another code for thought: public members Pin
patbob30-Oct-18 6:01
patbob30-Oct-18 6:01 
GeneralRe: Another code for thought: public members Pin
Gary Wheeler30-Oct-18 6:03
Gary Wheeler30-Oct-18 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   499 votes