Skip to content

Problem Solving

Published: at 12:00 AM

Problem Solving

PROBLEM SOLVING: Creating this application is 80% problem solving and 20% code. Let’s go through how to problem solve. 

Let’s run through some of the key ideas:

Let’s adapt that to the problem which is implementing the add stocktake functionality - expanding on each

1. Identify the problem

Let’s break this down into 3 sections - context, issue and why do I care?

Context: We need to implement the Add Stocktake functionality to the mobile app.

Issue: Need to understand what data I need to store, how I am going to store it, what validation logic I need, and how the user will input that data.

Why do I care? If we can streamline the input of quality data for stock, we would’ve cut down on a long and difficult task for managers and head office.


2. Research and Refine:

You’re likely not the first person to come across this problem. So use that person’s solution as a starting point.

So let’s break down the problems we have into smaller ones:


3. Psuedocode

Write out in the editor the logic of the application - as much as possible in the target language. In this case - it’d be Dart:

addStocktake function

define API caller - caller to DB
define screens(helper screens, stocktake form screens, confirmation screen, success/failure screens)
define layersIndex (helper screens = 1, stocktake form screens = 4, confirmation screen = 3, success/failure = 2)

display startingScreens (helper screens, stocktake form screen)

for itemCount = null item add to unaccountedItems array
for itemCount > 30 add item to unusualCount array

when pageCount = 5 display submit button

on user press of submit button:

- check items for duplicate entries and sum up total
- if unusualCount + unaccountedItems == null then display success/failure screen and submit data via API
- if unusualCount + unaccountedItems =/= null then display confirmation screen with relevant items

on user press of submit button on confirmation screen:

- display success/failure screen
- submit data via API
- show failure message and return to stocktake form screen by clearing screen by user button press
- show success message, clear the stocktake form screen, and then allow the user to clear the screen by button

Stocktake Form:

stocktakeFormScreen function

define stocktakeForm(locations(5), defaultItems, tableRows)
define stocktakeFormPages(locations = page number)

Also! Research! Check how the API works, and test it using Postman. Research how others completed it beforehand to see what is done.


4. Writing tests

There is a simple flow to testing:

For example in the addStocktake function:

test('to ensure that item count does not have invalid data types')

define itemCountTest = simulatedCount(mockData)

expect itemCountTest = true

define incorrectCountTest =/= simulatedCount(mockData)

expect incorrectCountTest = true

5. Implement

Do it as quickly as possible. Just get it working.

No - really, just try to get it done as quickly as possible.

6. Reflect

Get a good nights sleep. Take a 15 minute break. Drink some water. Do some exercise.

But do this to make your code better:

It’s always easier to refactor a complete piece of code - then to write a perfect piece of code.

Added thoughts - 30/07/2024

Basically the point is can you break down the problem until you get to a single line of code?

Consider supporting this blog