One danger of taking a break on a project

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
So I've been working on a fairly large project for some time.
I needed a GUI system in it that was flexible and the one's currently out there didn't quite suite my needs.
I wanted it to be light weight, very fast and cross platform.
I designed the GUI to function similar in nature to HTML / CSS but lighter weight.
I got the GUI frame work up and running and about that time I ended up needing to take a break for personal issues.
So a month later I come back to it and I am finding I have to relearn what I created. Honestly looking at it I'm kind of astounded I created it even though I know I did.

Example: I was trying to figure out how I was handling button clicks. The line I was finding in the event handler just seemed way to simple.
So ended up tracing it back and it was accessing a hastable for storing the buttons and testing if they were clicked or not and so on.
Not sure if it helps to know everything I am doing is in C & C++.

I usually have pretty light documentation in my code it is normally fairly obvious how stuff works and I put a few notes here and there when it isn't.
This is the first time I can honestly say I wish I made more extensive documentation on my own code.
Feel like my previous self is taking the current me back to school.

Just curious how many others took a break and feel like they lost a step in between.
Maybe this will save someone some work and warn them to create documentation and not run into my issue. Cost me 2 hours of time to relearn what I did all together.
 
  • Like
Reactions: Marzepain

I'm Not Thea Lundgren!

AKA: TotesNotThea
Donor
Jun 21, 2017
6,583
18,945
I always put as much documentation with projects as possible; treat it as though someone else might be continuing it after you and they don't know anything.

EDIT Or that ^^^ That works too! ;)
 
  • Like
Reactions: Back and Diconica

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,005
Cost me 2 hours of time to relearn what I did all together.
That's all? I would say that is pretty good, maybe it's a smaller system but that's not horrible. I'm used to reading other people's code, helping them debug it (mostly students), and I'm familiar with how code can look fairly abstract for fairly simple operations/reasoning, so I tend to document extensively as if I am making demo code for students. but I have 3 modes, either only writing vague notes and ideas, code is still ToDo, I write both code with good documentation, or I just had a huge idea last night and need to spend the whole day writing code as fast as possible. In those cases, if I don't go back and add notes (after connecting all the code together and testing it) it can easily take me a week to remap the new chunk of code and accurately add notes. The fun thing is, often when this happens, when I'm in the heat of the moment, and the later I go through the code, it is totally overcomplicated, and something that took me 2 weeks to try to make I rebuild in far less code in a single day. while it is not too uncommon to have to relearn one's own code, I think if you do it enough it is a good exercise, you start to become familiar with certain patterns of programming and your own habits.
 

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
That's all? I would say that is pretty good, maybe it's a smaller system but that's not horrible. I'm used to reading other people's code, helping them debug it (mostly students), and I'm familiar with how code can look fairly abstract for fairly simple operations/reasoning, so I tend to document extensively as if I am making demo code for students. but I have 3 modes, either only writing vague notes and ideas, code is still ToDo, I write both code with good documentation, or I just had a huge idea last night and need to spend the whole day writing code as fast as possible. In those cases, if I don't go back and add notes (after connecting all the code together and testing it) it can easily take me a week to remap the new chunk of code and accurately add notes. The fun thing is, often when this happens, when I'm in the heat of the moment, and the later I go through the code, it is totally overcomplicated, and something that took me 2 weeks to try to make I rebuild in far less code in a single day. while it is not too uncommon to have to relearn one's own code, I think if you do it enough it is a good exercise, you start to become familiar with certain patterns of programming and your own habits.
That two hours is probably what it is because of a few habits of mine.
I tend to write code to be as minimal as possible and performance orientated as it can. I don't write bloat code.
People tend to go in excess when it comes to trying to prevent errors. If they would use good programming habits to start with they could prevent errors rather than trying to catch them.

Take the hash table I mentioned above. I can't count the number of hash tables people used linked lists in creating them.
If you are using C++ use a vector instead its a shit load faster and cleaner.
Hell even if I was using C I would rewrite the vector library then write the linked list now. That vector is so useful in other ways and the performance is far better than a linked list any day of the week. You can find he vector source in various open source versions of the C++ library.

My code: Normally tells you what it is doing. In this case it did also. Just not enough.
Here is the line that had me stumped. Mind you this is C++.
Code:
clicked.insert(buttons[c].name,false);
It now has a note beside it to remind me that clicked is the name of the hashtable where button click events are stored.
This was actually part of the code that registered the buttons in the table. The actual click events are handled in the update loop which is a state system (switch).

The game engine currently sits at 1900 lines of code that includes the built in editor, spread out in 28 files.
It has a complete font glyph system with utf8 converter, resource manager to handle all assets, gui system, scripts system, File I/O system, keyboard handler, logger... Because I built various systems like that it has saved me a lot of repeated code. The systems that need to load files for example all use the file system, the hash table is used by the glyph, and language system, resource manager and gui. Anything that uses a resource be it an image or music or sound file... acquires it through the resource system that way it is only loaded once and can be used countless times by simply sharing a pointer to it.

I am still adding in features so I figure a few hundred lines more before my first release.

Looking back after I figured out how it was all working again. It felt obvious. Made me feel a little stupid in 2 ways.
The first being obviously not having notated what it does. The second how the hell could I not realize what it was doing it was so obvious.
 
  • Like
Reactions: Marzepain

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,005
I find it strange that many programmer prefer to try to invent or create their own code rather than try to use someone else's code, because it is more painful to learn how their code works than it is to have fun making your own.
 

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
I find it strange that many programmer prefer to try to invent or create their own code rather than try to use someone else's code, because it is more painful to learn how their code works than it is to have fun making your own.
There are generally two types of programmers. Those that want to know how stuff works and make the best product they can and then there are those that use dotnet for example. They simply want to create a product and they don't really care about the negative aspects of what they are using.
Take dotnet 4.5 gigabytes of required drive space. Lets put that in perspective it is larger than linux OS installed in most cases.
Anyone using it puts the burden of that on their customer. If they would bother to learn to code properly and not be lazy shits the program would probably in most cases take a few megabytes not including data and resources.

As for other programmers code and using it. Given the number of bad programmers out there it is understandable a lot of programmers don't want to learn someone else's.

It's not just that. Part of the problem is bad search engine algorithms and other factors.
Google hashtable c++ and I'd bet the top links to examples probably all point to a hash table using a linked list.
Or google how to make a resource manager.
Probably is GUI development / design. A lot of the results will be about using something like QT rather than actually building a GUI framework. Then a lot of the result will effectively tell you to look at other frame works. Few will actually discuss the various ways of looking at the project and implementing it. I didn't find one in a reasonable number of pages of links that actually resulted in any sort of actual tutorial around the topic certainly nothing on the order of it being a college subject being discussed.

Google and Bing more often than not when it comes to technical stuff promote sites that are getting more views over providing accurate substance when it comes to technical stuff. It's bad enough I run my own web crawler so I am not 100% dependent on other search systems.

As a result you have a lot of new programmers learning from half ass or shit programmers or trying to make heads or tales out of a large project that they don't have a full grasp on how it works.

All that stuff has to leave a negative taste in any season developers mouth. So yep I get 100% not wanting to use other people's code. However, if it is something like libsdl or another api that is built well I don't have an issue with it. I use stuff that works and will actually save me time. The fact is 90% of the time I can write my own code in the time it would take me to decipher someone else's and I usually can write better code than they did.
 
  • Like
Reactions: ririmudev

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,005
The fact is 90% of the time I can write my own code in the time it would take me to decipher someone else's and I usually can write better code than they did.
I get that feel. I have a love hate relationship with unity beause sometimes I can just work on my code, and then sometime unity's quirky behavior messes with me because I don't fully understand everything about it, so I jump on over back to monogame where the engine is 100% my own code... except now I need to use someone else 3D library since I don't want to go back to university to learn about to implement custom dual quaternion mesh skinning techniques.
 
  • Like
Reactions: Diconica

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
I get that feel. I have a love hate relationship with unity because sometimes I can just work on my code, and then sometime unity's quirky behavior messes with me because I don't fully understand everything about it, so I jump on over back to monogame where the engine is 100% my own code... except now I need to use someone else 3D library since I don't want to go back to university to learn about to implement custom dual quaternion mesh skinning techniques.
I hate to ask do you already understand quaternions. I'm asking because a lot of people don't.
There is actually decent material available for learning both quaternions and double quaternion skinning.
There are some colleges that have the course material online even.

Dual quaternion skinning isn't an super solution it is at best a start to a solution because it has a number of issues itself.
There are a number of ways people are attacking the various issues related to it.

The point here is you really don't need to go to college to learn it.

This is the more detailed version of the pdfs on here that start off looking the same.









 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,278
22,428
I'm not a programmer, but I have a html, css, php, javascript and c++ background (self taught), it's been ages though, so I often find myself wondering how something works only to realize that it's rather simple (feeling stupid every now and then included).
I usually look for specific examples, but more often than not I find code/snippets that (imo!) could be easier/shorter, code that is overblown for a simple task, so I try to find a simpler solution (not always successfull) and while I'm working on it I make a lot of comments for later usage.
Good habit, right?
Well when I re-use that code I tend to either delete the comments, or just copy the code itself and yes, that has caused me some headache some time, especially when I switch between projects.
 

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,005
This is the more detailed version of the pdfs on here that start off looking the same.
perfect, I literally had the open up in another tab (less details with the matrixes), and was worried I wasn't going to find better technical papers without going to my local university to see if I could access their database subscription.

as an electrical engineer I am more used to state-space matrixes, granted I had my share of laplace matrixes, but both of those are things you mainly calculate by hand to optimize for real time operation (ie keeping a jet fighter stable/robot stability), not so much doing matrix calculation by code as one transformation is applied to another (ie the compounding joints of a character rig). I just needed to identify/learn more about dual quaternions and their difference from linear, as the meshes I am working with are design for DQ for volume preservation, with corrective morphs applied to make things look natural.
 

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
perfect, I literally had the open up in another tab (less details with the matrixes), and was worried I wasn't going to find better technical papers without going to my local university to see if I could access their database subscription.

as an electrical engineer I am more used to state-space matrixes, granted I had my share of laplace matrixes, but both of those are things you mainly calculate by hand to optimize for real time operation (ie keeping a jet fighter stable/robot stability), not so much doing matrix calculation by code as one transformation is applied to another (ie the compounding joints of a character rig). I just needed to identify/learn more about dual quaternions and their difference from linear, as the meshes I am working with are design for DQ for volume preservation, with corrective morphs applied to make things look natural.
In case you don't already know this.
Not sure you know about "site" when it comes to google search. Type site:website what you are looking for and it will limit the search results to the site. You can however also do stuff like site:*.edu and it will pull from all edu sites.
Example "site:*.edu quaternion"
 
  • Like
Reactions: Marzepain

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
I'm not a programmer, but I have a html, css, php, javascript and c++ background (self taught), it's been ages though, so I often find myself wondering how something works only to realize that it's rather simple (feeling stupid every now and then included).
I usually look for specific examples, but more often than not I find code/snippets that (imo!) could be easier/shorter, code that is overblown for a simple task, so I try to find a simpler solution (not always successfull) and while I'm working on it I make a lot of comments for later usage.
Good habit, right?
Well when I re-use that code I tend to either delete the comments, or just copy the code itself and yes, that has caused me some headache some time, especially when I switch between projects.
I tend to think any decent programmer has experienced it. The one's who don't are probably those that really never try to push their own limits in it or rely far to much on others coding stuff for them.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,384
15,294
while it is not too uncommon to have to relearn one's own code,
I would even say that it's frequent, especially for people who do it as part of their job. The "good self-explaining code" everybody hear about come from those who study codding, not from those who practice codding.
Despite every good intentions you can have when you start your code, you quickly goes with the flow ; you don't do "this" because it's academical or because it's explicit, but because it's what should works. And once you start testing, you'll do it because it's what effectively works.
Then if you have some times, you go back to the documentation you put at the top of the code/function, and correct it... but it's if you have time.

In the end, while it's not a good practice, it's inside comments that generally are the best answer ; especially when it come to bug correction. One line saying, "this do that", can save a full day of thinking when you come back to your code. You'll still have to figure how the hell it achieve to "do that", but at least you don't have to guess this part.
In the end, when you're really satisfied by your code, or when it finally looks more like academical one, you can remove those comments and update the doc at the top of it.
But never ever remove the ones related to bug corrections... else you'll put back the bug soon or later. You wrote the code in a buggy way for a reason, and generally it was a good one ; you thought that it should be wrote like that. So if you come back to your code months later, you'll see it, and one of your first thought will be "but, it should be wrote like [the buggy way]"... I let you imagine what will happen next.


I think if you do it enough it is a good exercise, you start to become familiar with certain patterns of programming and your own habits.
And when you're starting (codding or using a given language), you can also see your progress.
 
  • Like
Reactions: Marzepain

Diconica

Well-Known Member
Apr 25, 2020
1,100
1,150
I would even say that it's frequent, especially for people who do it as part of their job. The "good self-explaining code" everybody hear about come from those who study codding, not from those who practice codding.
Despite every good intentions you can have when you start your code, you quickly goes with the flow ; you don't do "this" because it's academical or because it's explicit, but because it's what should works. And once you start testing, you'll do it because it's what effectively works.
Then if you have some times, you go back to the documentation you put at the top of the code/function, and correct it... but it's if you have time.

In the end, while it's not a good practice, it's inside comments that generally are the best answer ; especially when it come to bug correction. One line saying, "this do that", can save a full day of thinking when you come back to your code. You'll still have to figure how the hell it achieve to "do that", but at least you don't have to guess this part.
In the end, when you're really satisfied by your code, or when it finally looks more like academical one, you can remove those comments and update the doc at the top of it.
But never ever remove the ones related to bug corrections... else you'll put back the bug soon or later. You wrote the code in a buggy way for a reason, and generally it was a good one ; you thought that it should be wrote like that. So if you come back to your code months later, you'll see it, and one of your first thought will be "but, it should be wrote like [the buggy way]"... I let you imagine what will happen next.

And when you're starting (codding or using a given language), you can also see your progress.
The documentation my code does have gets there because of the way I tend to build my projects.
I Usually maintain an overall view of the project which has a general list of what all needs to be built.
Then I keep a to do list with finer detail and notes regarding how I figured out to solve an issue before it is maintained in the code.
Then as I work on a section of part of the project I put notes in as reminders to what I need to do the order of operation and so on. Some of that as the code is developed is simply changed into a line explaining what something does in general. Other times not so much it may just end up getting deleted because I end up moving it or it had to be contained inside something else and thus I never moved it I just ended up deleting it from where it was. Yea, that's my own laziness biting me in the ass. Because I am pretty sure that is exactly why there wasn't a note in this case there telling me where to look.

The only good part about my method it allows me to deal with much larger projects and not get bogged the hell down and I have generally few bugs to contend with through out the development cycle.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,384
15,294
The only good part about my method it allows me to [...]
It's not how you should look at it.

Does it works for you ? If yes, your method have all the possible good parts ; it can perhaps be improved, but it's already a good method. If no, you should really think about a better way to do it. And that's all.

Unless you work on a collaborative project, the only good practices are the practices that works for you.
I understand teachers who say the opposite, because it's clearly not a good way to learn codding. But if one intend to only code "for the pleasure", the academical way to do and the good practices matter less than his ability to understand what he do and why he do it.
 
  • Like
Reactions: Marzepain

Marzepain

Newbie
May 4, 2019
61
49
There are generally two types of programmers. Those that want to know how stuff works and make the best product they can and then there are those that use dotnet for example. They simply want to create a product and they don't really care about the negative aspects of what they are using.
Take dotnet 4.5 gigabytes of required drive space. Lets put that in perspective it is larger than linux OS installed in most cases.
Anyone using it puts the burden of that on their customer. If they would bother to learn to code properly and not be lazy shits the program would probably in most cases take a few megabytes not including data and resources.

As for other programmers code and using it. Given the number of bad programmers out there it is understandable a lot of programmers don't want to learn someone else's.

It's not just that. Part of the problem is bad search engine algorithms and other factors.
Google hashtable c++ and I'd bet the top links to examples probably all point to a hash table using a linked list.
Or google how to make a resource manager.
Probably is GUI development / design. A lot of the results will be about using something like QT rather than actually building a GUI framework. Then a lot of the result will effectively tell you to look at other frame works. Few will actually discuss the various ways of looking at the project and implementing it. I didn't find one in a reasonable number of pages of links that actually resulted in any sort of actual tutorial around the topic certainly nothing on the order of it being a college subject being discussed.

Google and Bing more often than not when it comes to technical stuff promote sites that are getting more views over providing accurate substance when it comes to technical stuff. It's bad enough I run my own web crawler so I am not 100% dependent on other search systems.

As a result you have a lot of new programmers learning from half ass or shit programmers or trying to make heads or tales out of a large project that they don't have a full grasp on how it works.

All that stuff has to leave a negative taste in any season developers mouth. So yep I get 100% not wanting to use other people's code. However, if it is something like libsdl or another api that is built well I don't have an issue with it. I use stuff that works and will actually save me time. The fact is 90% of the time I can write my own code in the time it would take me to decipher someone else's and I usually can write better code than they did.
I've seen this sentiment among programmers many times and the positive about it is the willingness to learn their trade. Many newbie programmers hack something together and when stuck find the shortest piece of code on StackOverflow.
Also the willingness to optimize for size and speed is a sign of perfectionism and that may be good but can lead to trouble.

I have 2 points to make:
1 Optimization for results in a business sense
The question is "What are you trying to achieve?"

2 Optimization for reuse in a design and ergonomic sense
The question is "Who is going to use your (code) product and how are they going to use it?"

The first makes tradeoffs possible like sacrificing speed or memory use for earlier delivery. Also having components or subsystems is inherently bad for performance, because it leads to local optimization of those components and systems, while the system as a whole may suffer.
As side note, Elon Musk started out as a programmer that was doing things in ASM and C, hating OO, but if he was still doing that he would not have a chance to reach mars.

The second is very hard to understand for somebody who is just trying to make it work. Your .Net remark really stung, because you probably don't know the situation of C/C++ before that (or java for that mater). I still have the CD of the the short lived .Net 1.0 version at home. The design of .Net standardized many language improvement that where floating around academia for decades. For instance, using a memory manager for C++ was possible for years before .Net, but it was little used and cumbersome.

I have to admit the whole thing took a turn when the managers got a hold of it and it became even worse when it became a thing for the marketing people. Luckily the managers and marketing people are infatuated with the cloud these days. The .Net Core versions are a lot better for it.

Designing code can be done on many levels. Consider this hierarchy:
  1. Language designer
  2. Library designer
  3. Framework designer
  4. Solution architect
  5. IT Pro/Maintainer
  6. Enterprise architect
On all those levels there are tradeoffs to make and they impact the people that work with the code. Many programmers are actually Solution architects, but they are either throwing tools, scripts, workflows or even people at the problem like a Enterprise architect or they are building frameworks, libraries or even there own language to solve the problem.
Judging the performance of anything involves defining the situation. If you want to judge a programmer you really need to define the situation. The same goes for a solution that is created for a problem situation.
 
Last edited: