Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to show your co-programmers that some methods are not yet implemented in a class when programming in C++

What approaches can you use when:

  • you work with several (e.g. 1-3) other programmers over a small C++ project, you use a single repository
  • you create a class, declare its methods
  • you don't have a time do implement all methods yet
  • you don't want other programmers to use your code yet (because it's not implemented yet); or don't want to use not-yet-implemented parts of the code
  • you don't have a time/possibility to tell about all such not-yet-implemented stuff to you co-workers
  • when your co-workers use your not-yet-implemented code you want them to immediately realize that they shouldn't use it yet - if they get an error you don't want them to wonder what's wrong, search for potential bugs etc.
like image 878
Czubaka Avatar asked Jul 22 '10 23:07

Czubaka


5 Answers

You should either, just not commit the code, or better yet, commit it to a development branch so that it is at least off your machine in case of catastrophic failure of your box.

This is what I do at work with my git repo. I push my work at the end of the day to a remote repo (not the master branch). My coworker is aware that these branches are super duper unstable and not to be touched with a ten foot pole unless he really likes to have broken branches.

Git is super handy for this situation as is, I imagine, other dvcs with cheap branching. Doing this in SVN or worse yet CVS would mean pain and suffering.

like image 145
baudtack Avatar answered Nov 16 '22 02:11

baudtack


Declare it. Dont implemented it. When the programmer use to call the unimplemented part of code linker complains, which is the clear hit to the programmer.

class myClass
{
    int i;
public:
    void print(); //NOt yet implemented
    void display()
    {
        cout<<"I am implemented"<<endl;
    }
};

int main()
{
    myClass var;
    var.display();
    var.print(); // **This line gives the linking error and hints user at early stage.**
    return 0;
}
like image 21
vrbilgi Avatar answered Oct 04 '22 00:10

vrbilgi


The simplest answer is to tell them. Communication is key whenever you're working with a group of people.

A more robust (and probably the best) option is to create your own branch to develop the new feature and only merge it back in when it's complete.

However, if you really want your methods implemented in the main source tree but don't want people using them, stub them out with an exception or assertion.

like image 14
Cogwheel Avatar answered Nov 16 '22 02:11

Cogwheel


I actually like the concept from .Net of a NotImplementedException. You can easily define your own, deriving from std::exception, overriding what as "not implemented".

It has the advantages of:

  1. easily searchable.
  2. allows current & dependent code to compile
  3. can execute up to the point the code is needed, at which point, you fail (and you immediately have an execution path that demonstrates the need).
  4. when it fails, it fails to a know state, so long as you're not blanketly swallowing exceptions, rather than relying upon indeterminable state.
like image 10
Nathan Ernst Avatar answered Nov 16 '22 01:11

Nathan Ernst


I would not check it into the repository.

like image 7
Anthony Avatar answered Nov 16 '22 03:11

Anthony