Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C#: Using accessors and private functions/variables

  • 12-08-2011 11:23pm
    #1
    Registered Users, Registered Users 2 Posts: 377 ✭✭


    If you are working on a solo project is it a complete waste of time to use properties/accessors and private/protected keywords? Are they only useful in a group project situation?


Comments

  • Registered Users, Registered Users 2 Posts: 375 ✭✭unknownlegend


    If you are working on a solo project is it a complete waste of time to use properties/accessors and private/protected keywords? Are they only useful in a group project situation?
    I don't think so, you should try use best programming practice even on solo projects. This will stand in your favour when working on group projects. Look into StyleCop since you specifically mention c#. Some of the rule: I don't agree with but you can change the rule engine easily :)


  • Registered Users, Registered Users 2 Posts: 1,311 ✭✭✭Procasinator


    It wouldn't be a complete waste of time as it means you a putting thought into the design system. It also will allow to refactor easier.

    The only time it may be a complete waste of time to put much thought into is if it is a throwaway project. Such as generating a once-off report or similar activity.


  • Registered Users, Registered Users 2 Posts: 7,987 ✭✭✭Trampas


    fxcop also.

    Maybe your solo project could be broken down into smaller projects.

    should get into a good habit of always improving on every app you write.

    even if it is a tiny change but means it is better and takes longer to learn how to write the code.

    don't try and cut corners even if it works.


  • Registered Users, Registered Users 2 Posts: 297 ✭✭stesh


    If you are working on a solo project is it a complete waste of time to use properties/accessors and private/protected keywords? Are they only useful in a group project situation?

    What?

    Different access levels are pretty fundamental to object-oriented programming.


  • Registered Users, Registered Users 2 Posts: 3,945 ✭✭✭Anima


    Try and write any non-trivial program with those ideas and you'll see the value of encapsulation fairly fast!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Bad code is bad code, regardless of the project. If you have to do maintenance or get through some kind of quality assurance (system test/UAT) then you'll be grateful you didn't cut corners.


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    For classes that typically hold nothing but data, I use C#'s automatic properties. You see that all over the place.

    For actual business logic code, I think it's more important to get your interfaces right even if you're banging out quick and dirty code. That way, an interface acts as a contract to whatever implementation you have under the hood. It's a good habit to get into!

    But then even THAT's not too important when you start out, code evolves. A few crappily written classes can be refactored into something much bigger and be fixed while you do it.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I couldn't even begin to count the amount of projects that started out as some quick little utility that only I would use, but later grew into something much larger, more complex, and was widely deployed.

    I learned long ago to always do it right from the start, otherwise something that was quick and simple soon becomes a huge unwieldy mess.


Advertisement