<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.2">Jekyll</generator><link href="https://chocolatedrivendevelopment.com/feed/by_tag/list.xml" rel="self" type="application/atom+xml" /><link href="https://chocolatedrivendevelopment.com/" rel="alternate" type="text/html" /><updated>2025-08-04T06:59:12+00:00</updated><id>https://chocolatedrivendevelopment.com/feed/by_tag/list.xml</id><title type="html">Chocolate Driven Development</title><subtitle>The blog Chocolate Driven Development contains things to help in making your software creation better for the business, as well as for the developers.</subtitle><entry><title type="html">Choosing a language or framework</title><link href="https://chocolatedrivendevelopment.com/2021/09/29/choosing-a-language-or-framework/" rel="alternate" type="text/html" title="Choosing a language or framework" /><published>2021-09-29T00:00:00+00:00</published><updated>2024-02-16T00:00:00+00:00</updated><id>https://chocolatedrivendevelopment.com/2021/09/29/choosing-a-language-or-framework</id><content type="html" xml:base="https://chocolatedrivendevelopment.com/2021/09/29/choosing-a-language-or-framework/"><![CDATA[<p>When starting a new project,
or adding a new module to an existing project,
the question of language and framework arises.
This is a list of things that I consider when picking a language.</p>

<h2 id="existing-ecosystem">Existing ecosystem</h2>

<p>If you already have a handful of different technologies in the project,
it is hard to maintain a good level of knowledge for them.
Adding another language or framework will not help.
It most of the code is stable,
so that it never change,
and simple enough to be replaced easily when an upgrade is necessary,
this is less of an issue.
But if you have a lot of code that is still actively maintained by the team,
pick something that is already existing in the ecosystem.
If the technical requirements are new,
say you will build the first native smartphone app for the project,
exceptions must be made.
If you are afraid that the technology you have won’t be fast enough,
write a small test. Guess at the part that will demand the most of the system,
implement it for a load test in a technology you already have.
Then you will know if you need to introduce more complexity to the project or not.</p>

<h2 id="knowledge-in-the-team">Knowledge in the team</h2>

<p>If you do not have a lot of code in place,
but you have the people,
let them decide.
Not from the shiny toys they want to try, but something they have experience in.
Set aside time to experiment on new technology
outside of the main project to play with the shiny stuff.
That is not for production.
If you need to introduce new technology,
as in the smartphone example above,
make sure that the entire team learns enough
to at least be able to fix a simple bug and deploy to production.</p>

<h2 id="culture-of-the-technology">Culture of the technology</h2>

<p>Languages and frameworks have communities.
One of my favourite podcasts, <a href="https://www.greaterthancode.com/">&gt;Code</a>,
have panelists who learned Ruby
because of the people who go to Ruby conferences.
If you need to introduce something new,
try to get a feel of the people who already use the technology.
Read the code of conduct for the major conferences.
Look at the tone in replies to bug reports and feature requests.</p>

<h2 id="availability-when-hiring">Availability when hiring</h2>

<p>It you do not have a team,
or the team needs to grow, can you hire for the technology?
Senior developers should,
in my opinion, be able to learn any technology quite quickly.
But it might be easier to choose something
that people already know and use.
I would say that this is extra important
if you are not the owner of the product,
but helping a customer to get it started.</p>

<h2 id="patterns-and-practises">Patterns and practises</h2>

<p>Beside the “people culture” around a technology,
there is also a programming culture.
Look at the testing frameworks and what patterns people use.
Will it be easy to find high quality examples online?
Is the standard way of doing things containing patterns
that will prevent you from following good practise?
An example was a framework
that encouraged scripts that swapped lines in configuration files,
instead of allowing different configurations when building your target.
That practise then also leaked into other parts of our project,
wreaking havoc in the setup of originally more sensible frameworks.
People will learn from what they do,
don’t bring technology with bad practises into your ecosystem.
Overly powerful testing tools is also a smell.
If you need to “power mock” something, that is a sign of bad design.
If all the focus is on integrated tests, that is also a warning.</p>

<h2 id="the-actual-language">The actual language</h2>

<p>Yes, if you do not have very specific requirements,
that you have verified are true,
the actual language comes last.
For projects that are totally new,
where you know you have enough people,
and multiple languages are good candidates,
you might need to consider the language design.
In that case my preference is to look for two things:
integrity and decoupling.
How easy is it to make sure
that my assumptions of the state of the running program is correct?
This contains things as dealing with null, memory, types and exceptions.
How easy is it to write modular code?
That has to do with things as interfaces or protocols,
the status of functions,
imports and the
<a href="https://en.wikipedia.org/wiki/Liskov_substitution_principle">Liskov substitution principle</a>.
What I value in a language change as I learn more.</p>

<p>Writing code for people (including yourself)
is harder than writing it for the computer.
That is why the people aspect of a technology is more important to me
than the technical aspects.
That is true also when choosing a language or a framework.</p>]]></content><author><name>Ester Daniel Ytterbrink</name></author><category term="code" /><category term="list" /><summary type="html"><![CDATA[Languages and frameworks will be part of a larger context. Consider the existing environment when choosing a language or framework.]]></summary></entry><entry><title type="html">The best kind of code</title><link href="https://chocolatedrivendevelopment.com/2021/09/09/the-best-kind-of-code/" rel="alternate" type="text/html" title="The best kind of code" /><published>2021-09-09T00:00:00+00:00</published><updated>2021-09-09T00:00:00+00:00</updated><id>https://chocolatedrivendevelopment.com/2021/09/09/the-best-kind-of-code</id><content type="html" xml:base="https://chocolatedrivendevelopment.com/2021/09/09/the-best-kind-of-code/"><![CDATA[<blockquote>
  <ol>
    <li>Code never written</li>
    <li>Code never read</li>
    <li>Code never changed</li>
    <li>Code telling a story</li>
  </ol>
</blockquote>

<p>The best code is the one we never write.
Perhaps user research shows that there will be no value.
Or there might be a library we could use, or some service.</p>

<p>If we have to write code it should have an interface
so clear that it tells all there is to know.
If the code can be trusted,
and we know how to use it,
there is no need to read it.</p>

<p>If we need to read it,
at least it should have so little responsibility
that there is only one reason to change it.
And if there is only one reason to change it,
nothing else should be at risk breaking due to that change.</p>

<p>If we have to change it,
like really change it,
keeping some functionality and changing other parts.
Then it should at least tell us
so much about it self that we know what is going on.</p>

<p>This is my code type top-list. What is your favourite kind of code?</p>]]></content><author><name>Ester Daniel Ytterbrink</name></author><category term="code" /><category term="list" /><summary type="html"><![CDATA[Code never written, code never read, code never changed and code telling a story]]></summary></entry><entry><title type="html">A language agnostic debugging list</title><link href="https://chocolatedrivendevelopment.com/2021/06/09/a-language-agnostic-debugging-list/" rel="alternate" type="text/html" title="A language agnostic debugging list" /><published>2021-06-09T00:00:00+00:00</published><updated>2024-02-16T00:00:00+00:00</updated><id>https://chocolatedrivendevelopment.com/2021/06/09/a-language-agnostic-debugging-list</id><content type="html" xml:base="https://chocolatedrivendevelopment.com/2021/06/09/a-language-agnostic-debugging-list/"><![CDATA[<p>Checklists are nice cognitive tools.
This one can also work as a reminder when designing code.
Please come with feedback and suggestions for improvement.</p>

<p>It is not always the case that we immediately spot the reason for an error in a codebase.
Sometimes it is hard to find due to the design.
In other cases the definition of correct behaviour is the problem.
It might also be a lack in understanding when it comes to the technology used.
This checklist is useful regardless of your knowledge of the language you are debugging.
Depending on domain knowledge, technical knowledge and the state of the code base,
how long the steps take and what information they give, will vary.
This is, as most knowledge work,
best done together with someone else,
or with an entire team.</p>

<h2 id="a-test">A test</h2>

<p>Write a test,
of some kind,
that captures the unintended behaviour.
In worst case it is a description of steps to take
written on a piece of paper.
Best case is a unit test.
This will define where we see the problem,
with its setup and the state it leaves the program in.</p>

<h2 id="specifications">Specifications</h2>

<p>Do we know for sure that this is a problem,
not just a state where the behaviour is not clearly defined?
Make sure that we know what the code is supposed to do
in this particular case.</p>

<h2 id="location">Location</h2>

<p>Are we sure that this is where the problem is caused? Check that the in-data is correct,
and that the data out is not as expected.
Try to narrow it down,
define as little code as possible where the error might be.</p>

<h2 id="regression">Regression</h2>

<p>Has it ever worked?
If it has, what has changed since then?
Version control is your friend here.</p>

<h2 id="static-analysis">Static analysis</h2>

<p>Is the IDE saying anything?
A real development environment uses parts of the same algorithms
as the compiler/transpiler/interpreter,
to be able to give hints and syntax highlighting.
There is also often static code analysis tools
that can highlight practises that make the code fragile.
Use tools.</p>

<h2 id="surrounding-state">Surrounding state</h2>

<p>Are there inputs, not stated as such, in the code we are looking at?
Some code use state that is external in some way.
One way to check this is by trying to write a unit test,
instead of an integration test.
What do we need in our setup to make it work?
The state could be a global variable used by a collaborator,
today’s date, or some settings in the system.
Make sure that we know all the <em>actual</em> input data to the code we are investigating.
Try to make the implicit input explicit when testing the code.</p>

<h2 id="comparing">Comparing</h2>

<p>If there is comparing going on,
is it done correctly (for that language)?</p>

<h2 id="things-missing">Things missing</h2>

<p>Do we know what could be null/nil/empty?
Keeping null-checks at the boundaries of code makes this easier.
Use the tools the language provide to deal with missing data.</p>

<h2 id="data-structures">Data structures</h2>

<p>Are data-structures used as intended?
If iteration happens,
are the boundaries the right one?
Do the data-structures have any quirks in this framework?</p>

<h2 id="language-specifics">Language specifics</h2>

<p>Are there other language features that could be a problem? In Python,
default arguments can turn into singletons.
In ObjectiveC a method call on a deallocated object will return 0,
or nil, but succeed.
Try to rewrite the code, even if it turns it bulkier,
just to see if misdirected “cleverness” might be the problem.
Then read the documentation to understand what happens if the behaviour changes.</p>

<h2 id="flow">Flow</h2>

<p>Is the flow of execution as we think it is?
Use a debugger to step through the calls, following the control flow.
Test cases can also be run in debug-mode.
Make sure that there are no code skipped.
One example is if code is executed as part of a condition,
that is already evaluated as true, and therefore skipped.</p>

<h2 id="threads">Threads</h2>

<p>Are we working with asynchronous code?
If we are, then make sure that it is done correctly.
Test ways to make sure that all of the suspect code is run synchronous,
to eliminate logic errors that are not timing related
, even if the code can never run like that in production.</p>

<h2 id="identity">Identity</h2>

<p>Is everything what we think it is?
Is the runtime scope clear?
Do we have inheritance, this/self references,
variables or functions that might shadow each other,
or other things that might not be what we assume that they are?
Do we reuse variable names or references?
Might there be things where ownership is unclear and it is garbage collected?
Use a debugger, or print statements, to check that things are what we expect.
(<a href="https://www.youtube.com/watch?v=IyYnnUcgeMc">Playing Destiny’s Child while doing this is optional</a>,
but it is a good reminder that scope in JavaScript is tricky.)</p>

<h2 id="self-care">Self care</h2>

<p>Take a break, if you have not already.
At this point I might start searching the internet,
or try writing a question at Stack Overflow.
(Often the solution is in writing the post, not posting it.)
I might also call a friend.
My experience is that the harder the answer is to find,
on the internet,
the more likely it is that the mistake made is really basic.</p>

<p>Hope this list helps.
I will use it the next time I get stuck on code not working as I intended.</p>

<p>How do you find your mistakes?
Do you have anything to add?
Have I missed anything language specific that is not included in the steps above?</p>]]></content><author><name>Ester Daniel Ytterbrink</name></author><category term="quality" /><category term="code" /><category term="list" /><summary type="html"><![CDATA[A cognitive tool in shape of a list of things that often go wrong when writing code. Nice to have when you get stuck.]]></summary></entry><entry><title type="html">TDD cheats, tricks to dodge the hard parts of testing</title><link href="https://chocolatedrivendevelopment.com/2021/04/16/tdd-cheats-tricks-to-dodge-the-hard-parts-of-testing/" rel="alternate" type="text/html" title="TDD cheats, tricks to dodge the hard parts of testing" /><published>2021-04-16T00:00:00+00:00</published><updated>2021-04-16T00:00:00+00:00</updated><id>https://chocolatedrivendevelopment.com/2021/04/16/tdd-cheats-tricks-to-dodge-the-hard-parts-of-testing</id><content type="html" xml:base="https://chocolatedrivendevelopment.com/2021/04/16/tdd-cheats-tricks-to-dodge-the-hard-parts-of-testing/"><![CDATA[<p>Test Driven Development is sometimes hard.
I have found some “cheats” to make it easier.</p>

<h3 id="test-gets-too-big-and-complicated">Test gets too big and complicated</h3>

<p>Split up the thing you are testing.
Create a collaborator and test that separately or just split up the function.
Splitting up view logic and rendering is nice and make testing easier.</p>

<p><em>Cheat codes:</em> “separation of concerns”,
“model view controller”, “view model - model view”</p>

<h3 id="state-makes-things-hard">State makes things hard</h3>

<p>Sometimes the test depends on a system state
or some other thing that is hard to control in the test.
Inject the tricky thing as a dependency (fancy word for parameter)
to the function/method.
Today’s date should always be injected as a dependency if used.</p>

<p><em>Cheat codes:</em> “dependency injection”</p>

<h3 id="the-framework-i-am-using-has-no-test-doubles">The framework I am using has no test doubles</h3>

<p>Wrap the framework in your own code
and create a double for the wrapper.
That will also isolate the framework,
make it easier to adapt, replace and upgrade.</p>

<p><em>Cheat code</em>: “ports and adapters”, “Hexagonal design”</p>

<h3 id="i-do-not-understand-mocks-stubs-fakes-and-all-the-tricky-words">I do not understand mocks, stubs, fakes and all the tricky words</h3>

<p>Try to avoid side effects in your code as far as possible.
Isolate necessary side effects (as sending/getting data)
to specific areas of the code
— the shell.
A function or method that does not return anything,
aka a void function,
is a sign of a side effect in action.
Make sure void functions do not contain any conditionals (if etc.).
Write the rest of the code without side effects,
levering data. If that is the only place containing logic,
it is the part most important to test.
And that can be done without tricky things as mocks.</p>

<p><em>Cheat code:</em> “pure functions”, “io monads”, “functional core - imperative shell”</p>

<p>Sources:</p>

<p><a href="https://www.destroyallsoftware.com/talks/boundaries">https://www.destroyallsoftware.com/talks/boundaries</a></p>]]></content><author><name>Ester Daniel Ytterbrink</name></author><category term="quality" /><category term="code" /><category term="list" /><summary type="html"><![CDATA[Test Driven Development (and unit testing in general) is easier when some things are avoided or encapsulated. Here are four problems faced when unit testing and their solutoins.]]></summary></entry><entry><title type="html">My health checkup checklist for software projects</title><link href="https://chocolatedrivendevelopment.com/2021/03/15/my-health-checkup-checklist-for-software-projects/" rel="alternate" type="text/html" title="My health checkup checklist for software projects" /><published>2021-03-15T00:00:00+00:00</published><updated>2021-03-15T00:00:00+00:00</updated><id>https://chocolatedrivendevelopment.com/2021/03/15/my-health-checkup-checklist-for-software-projects</id><content type="html" xml:base="https://chocolatedrivendevelopment.com/2021/03/15/my-health-checkup-checklist-for-software-projects/"><![CDATA[<p>What is good code?
That is not a question easily answered.
But sometimes you need to do a quick assessment
on the state of a software project.
When I get my hands on a new collection of code,
these are the steps I take for a first assessment
on how easy the project will be to work with.
How far I get depends on how much time I have and how the code is.
Language and framework will also matter for how important each step is,
and how well I can answer the questions.
Some findings will make me entirely skip the rest of the section,
as if there are no tests the rest of that section makes no sense.
There are also not always a “right” and a “wrong” answer to the questions,
not only objectively but also from my subjective view.
For me, the most important thing is to know what I am getting myself into.
I hope it can be helpful for others too. My steps are:</p>

<h2 id="1-get-the-code">1. Get the code</h2>

<ul>
  <li>How are the dependencies managed?</li>
  <li>Are there a lot of deprecations and exploits found for the dependencies?</li>
  <li>Is the code “older” than its first commit?
That can happen if the project starts as a copy of an older project.</li>
  <li>If it should compile, does it compile?</li>
</ul>

<h2 id="2-run-the-code">2. Run the code</h2>

<ul>
  <li>Is there a readme?</li>
  <li>If there is a readme and I follow it,
will I have the project running on my computer?</li>
  <li>If the readme is missing, or is not leading to a running project,
what is missing? How much work would it be to fix it?</li>
  <li>How are secrets handled?</li>
  <li>Do I need anything besides the code to run things on my computer?</li>
  <li>Is the setup extra complicated compared to similar projects?</li>
  <li>Is the project prepared for new developers in some other way than a readme?</li>
</ul>

<h2 id="3-tests">3. Tests</h2>

<ul>
  <li>Are there tests?</li>
  <li>It there are tests, can I run them after following the readme?</li>
  <li>Can I run the tests on a computer not connected to the internet?</li>
  <li>What is the coverage for the tests, using metrics available?</li>
  <li>What is the proportion between unit tests and integration tests?</li>
  <li>Are the tests correctly labeled as unit/integration/system…
tests depending on what they do test?</li>
  <li>How is sensitive information, as secrets, handled for tests?</li>
  <li>How is the test data managed?</li>
  <li>Can I break the tests by changing the code?</li>
  <li>If I change the code will it break any tests?</li>
  <li>How much work is it to write the next test?</li>
</ul>

<h2 id="4-read-the-code">4. Read the code</h2>

<ul>
  <li>Can I see the domain in the naming and/or the types?</li>
  <li>How much code is there?
In how big chunks is it grouped (files, classes, functions)?</li>
  <li>Are there private/inner methods/functions/objects?</li>
  <li>Is there a linter? Does it produce any errors or warnings?
What kind of rules are enforced?</li>
  <li>Does the code have the feel of the language it is written in
or can I sense an “accent” from another programming language?</li>
  <li>How are external dependencies used?
Are they isolated or intertwined with the business logic?</li>
  <li>How is data transfer done (network/storage)?
Is it scattered over the code or done in one place?</li>
  <li>Are there a lot of dependencies/imports for each piece of code?</li>
  <li>How is error handling done?</li>
  <li>What does the cyclomatic complexity look like in general?
How is control flow managed? How is iteration and data manipulation done?</li>
  <li>Are there global state,
magic numbers or other implicit dependencies for objects and functions?</li>
  <li>How big portion of the code
do I need to read more than once to understand what it does?</li>
  <li>If I try to refactor the code somewhere random,
perhaps extracting a method, how hard is it?</li>
</ul>

<h2 id="5-version-control">5. Version control</h2>

<ul>
  <li>How big are the changes in the commits?</li>
  <li>How many files do each commit touch?</li>
  <li>Can i make sense of the messages?</li>
</ul>]]></content><author><name>Ester Daniel Ytterbrink</name></author><category term="code" /><category term="quality" /><category term="list" /><summary type="html"><![CDATA[A list of aspects to consider when getting to know a new software project and assessing how easy it will be to work with.]]></summary></entry></feed>