INDAPlus21 / INDAPlus21/ogronman-task-7

Pass

Open
#1 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Very well done Oskar!

But why do you plague me with spagetti? It hurts.
Your code:

int elemLenH = 0;
if (height % 2 == 0)
{
    elemLenH = height / 2 - 1;
}
else
{
    elemLenH = (height) / 2 - 1;
}

int elemLenW = 0;
if (height % 2 == 0)
{
    elemLenW = width / 2 - 1;
}
else
{
    elemLenW = (width) / 2 - 1;
}

Proper:

int elemLenH = height / 2 - 1;
int elemLenW = width / 2 - 1;

In this case of C data structures, a length variable is a godsend for readability. Let me also pitch ternary operators.
Your code:

qsort (y, sizeof(y)/sizeof(*y), sizeof(*y), comp);
//...
int elements = 0;
if(/*...*/){
    elements = sizeof(y)/sizeof(*y)/2;
}else{
    elements = (sizeof(y)/sizeof(*y)+1)/2;
}

With yLength:

int length = sizeof(y)/sizeof(*y);

qsort (y, length, sizeof(*y), comp);
//...
int elements = /*...*/ ? length/2 : (length+1)/2;

I would really have liked to play your dino game, but don't know which conio you're utlizing. Please push external libraries in the feature (or executables for Windows-plebs).

Keep it up!

Software Development Cycles

  1. Programmer produces code he believes is bug-free.
  2. Product is tested. 20 bugs are found.
  3. Programmer fixes 10 of the bugs and explains to the testing department that the other 10 aren’t really bugs.
  4. Testing department finds that five of the fixes didn’t work and discovers 15 new bugs.
  5. Repeat three times steps 3 and 4.
  6. Due to marketing pressure and an extremely premature product announcement based on overly-optimistic programming schedule, the product is released.
  7. Users find 137 new bugs.
  8. Original programmer, having cashed his royalty check, is nowhere to be found.
  9. Newly-assembled programming team fixes almost all of the 137 bugs, but introduce 456 new ones.
  10. Original programmer sends underpaid testing department a postcard from Fiji. Entire testing department quits.
  11. Company is bought in a hostile takeover by competitor using profits from their latest release, which had 783 bugs.
  12. New CEO is brought in by board of directors. He hires a programmer to redo program from scratch.
  13. Programmer produces code he believes is bug-free…

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the C code containing elemLenH, elemLenW, qsort, and the dino game's conio dependency; review the duplicated calculations and determine how the external library is expected to be supplied. Done means the cleanup is applied and the game can be built and played with its dependency available.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, game-dev
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.