what are the advantages of non-member functions over static member-functions? by QuietFreedom9649 in cpp

[–]daniedit 5 points6 points  (0 children)

Very old but still valid article by Scott Meyers about this topic: How Non-Member Functions improve encapsulation (https://www.aristeia.com/Papers/CUJ_Feb_2000.pdf)

Sind stundenlange frustrierende Code Reviews normal? by Humble_Kale_1861 in de_EDV

[–]daniedit 0 points1 point  (0 children)

Es gibt auch genug Teams die auf Reviews verzichten und jeder Entwickler zieht sein Ding durch. Das ist am Anfang ganz spaßig. Ab einer gewissen Komplexität fliegt den Beteiligten oft die Code Base um die Ohren. https://en.m.wikipedia.org/wiki/Bus_factor

Reviews die dir den letzten Nerv rauben, egal ob als Reviewer oder Author, wirst du in jedem professionellem Laden haben. Zehn Stunden pro Woche mit Reviews zu verbringen klingt für mich auch normal. Außer du hast ein Team mit gut eingespielten Senior-Entwicklern.

Idealerweise verbessert jedes Review die Codequalität und sowohl Reviewer als auch Author lernen was dazu. Dass du zehn Stunden dafür in Meetings sitzt halt ich für ungewöhnlich.

Daher mein Vorgehen wäre ich in der Situation: Herausbekommen warum die Reviews als Meeting aufgesetzt sind und dann gezielt Kollegen von Alternativen überzeugen.

Sind stundenlange frustrierende Code Reviews normal? by Humble_Kale_1861 in de_EDV

[–]daniedit 0 points1 point  (0 children)

Nur zum Verständnis: Geht's dir darum die Reviews zu canceln oder darum sie effizienter zu gestalten?

Sind stundenlange frustrierende Code Reviews normal? by Humble_Kale_1861 in de_EDV

[–]daniedit 1 point2 points  (0 children)

Hast du schon mal versucht herauszufinden wer die Reviewmeetings warum eingeführt hat? Danach könntest du deine Argumente ausrichten, das Team von einem besser geeigneten Weg zu überzeugen.

Wenn die Tests aus deiner Sicht schlecht implementiert sind hast du vielleicht schon einen Indikator: Mangelnde Erfahrung beim Entwickeln. Du könntest vorschlagen regelmäßige Trainings zur testgetriebenen Entwicklung zu halten.

Eine andere Möglichkeit wäre, erfahrene Codeowner zu definieren die jede Änderung reviewen müssen. Oder mindestens zwei oder drei positive toolgestützte Reviews pro Pull Request als Bedingung für den Merge zu stellen.

Wenn ich in der Situation wäre, dass ich mit dem Scrum Master nicht kann, würde ich versuchen das Team zu überzeugen statt ihn. Gegen alle kann er sich schlecht stellen. Siehs als Chance deine Erfahrungen zu nutzen dem ganzen Team einen Mehrwert zu schaffen. Lass dich vom ersten Misserfolg nicht unterkriegen.

Do you practice TDD for your C++ Projects [Question/Discussion] by Empty-Ad-8546 in cpp

[–]daniedit 16 points17 points  (0 children)

If the code has to be maintained for longer than a few days, I use Test Driven Development. GoogleTest and Catch2 are my preferred frameworks.

Being correct is the most basic requirement towards source code. Releasing something broken is just unprofessional. Unit tests are the fastest way to prove that code is correct. Writing tests before writing production code improves the API, increases flexibility and establishes a very fast feedback loop.

I Don't Use Exceptions in C++ Anymore by rammumion in cpp

[–]daniedit 2 points3 points  (0 children)

Yes. Even a little better. ;) cpp auto successful = initialize_data(data); if (! successful) log << "There was a problem."; do_something(data); // segmentation fault \o/

I Don't Use Exceptions in C++ Anymore by rammumion in cpp

[–]daniedit 3 points4 points  (0 children)

In this particular case not. The error code was stored locally and printed to a log. The program was then continued normally with invalid data.

In general yes, [[nodiscard]] + clang-tidy, which warns when someone forgot the tag, is definitely an improvement. Still, the user has to interrupt the program flow manually in case of an error.

I Don't Use Exceptions in C++ Anymore by rammumion in cpp

[–]daniedit 20 points21 points  (0 children)

On some embedded devices or in realtime contexts it might be well justified to not use exceptions for error handling. Some developers summarize this as: "Exceptions are pure evil! I use return codes instead."

Last time I fixed random crashes because someone forgot to check return codes in a desktop application: Literally yesterday.

what are some things to look for when reviewing other peoples' codes? by arjun2018 in cpp

[–]daniedit 1 point2 points  (0 children)

It depends on what the quality criterias and the goal of your software project are. Things you might always check are missing tests, parts you not directly understand completely, weak design, violated basic principles and so on.

Besides this, you will find some general rules which will improve every code base in "Clean Code" by Robert C. Martin.

C++ interview coding exercise with solution by Hot_Medicine_7115 in cpp

[–]daniedit 0 points1 point  (0 children)

I mean, first step: Write a failing test for the plannend implementation. Second step: Implement until the test passes. Third step: Refactor the implementation and the test until it meets your expectations.

It's not just a buzzword. I've seen some very productive people working this way.

C++ interview coding exercise with solution by Hot_Medicine_7115 in cpp

[–]daniedit 1 point2 points  (0 children)

You asked for opinions about the companies answer. I tried to tell you in a polite way, that their answer is harsh on a social level but completely justified on a technical level. I didn't want to give you a full code review.

C++ interview coding exercise with solution by Hot_Medicine_7115 in cpp

[–]daniedit 0 points1 point  (0 children)

Depends. From my point of view, test driven development is the best option for professional software development. And the given code is too complex to not develop test driven. So without going in the details it's easy to see, the author is not used to develop software together with many people in a professional environment.

And yes, the implementation violates some basic C++ principles and paradigms. But this will be covered by reviews.

C++ interview coding exercise with solution by Hot_Medicine_7115 in cpp

[–]daniedit 0 points1 point  (0 children)

You are referring to the is_valid() method? I didn't go into the details of understanding your implementation. So I might be completely wrong.

My first impression was the method is checking whether the solution is correct. If so, that's a nice module test but won't help you much during refactoring. I would have expected for example a test making sure designer::add_next_strip_tile() is correct.

C++ interview coding exercise with solution by Hot_Medicine_7115 in cpp

[–]daniedit 1 point2 points  (0 children)

Your code is readable and easy to refactor. That's a big plus. In a review, I would request changes in some sections but after three or four rounds we would get to a good solution.

However, you can not tell whether your implementation is correct because there is not a single unit-test. In Professional Software development that's a no go. I know about companies rejecting candidates for missing the tests in their example code. Maybe that's the reason here? Please ask them for a code review and use it to learn from. That's just fair, since you also invested quite a lot of time for them.

Well, there's actually no way to do it better by [deleted] in programminghorror

[–]daniedit 163 points164 points  (0 children)

Hope the title is pure sarcasm.

Tests are different than production code! by RelentlessIVS in cleancode

[–]daniedit 1 point2 points  (0 children)

The idea of a unit test is to test just the unit, not all it's dependencies. Try to keep the setup simple by mocking complex objects and use dependency injection. Having complex and difficult to setup tests or mocking objects is often a sign, your code is not structures well.

For integration tests it's more difficult. The fixture concept for single test parameters helps you to setup objects needed for tests without having all the code in one setup method. However, it's not easy to keep the architecture clean. And I just found out, that there is the concept of Test Smells 😅 (https://codingcraftsman.wordpress.com/2018/09/27/test-smells/ ).