Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Newbie, junior, senior programmer, Simple POS system

views
     
TSWongGei
post Feb 20 2023, 12:29 PM, updated 3y ago

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
user posted image

Requirement,

Create a simple POS system that take in customer order and calculates the total amount of the order.

This seems like a simple question that suits 1st assignment of the programming language class.

Let see how the Newbie, Junior Programmer, Senior Programmers' work.

And discuss why the program classified as such (N,J,S)

This post has been edited by WongGei: Feb 20 2023, 12:30 PM
angch
post Feb 20 2023, 07:06 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
CODE

# Define the menu with prices
menu = {
   "Hamburger": 5.00,
   "Cheeseburger": 6.00,
   "Hot Dog": 4.00,
   "French Fries": 3.00,
   "Soda": 1.50,
   "Water": 1.00
}

# Initialize variables
order_total = 0.00
order_items = []

# Take customer order
while True:
   item = input("Please enter an item name (or 'done' to complete the order): ")
   if item.lower() == "done":
       break
   elif item in menu:
       order_items.append(item)
       order_total += menu[item]
       print(f"{item} added to order (total: ${order_total:.2f})")
   else:
       print("Sorry, that item is not on the menu.")

# Print order details
print("\nOrder Summary:")
for item in order_items:
   print(f"- {item}: ${menu[item]:.2f}")
print(f"Total: ${order_total:.2f}")


Creating a Point of Sale (POS) system can be useful for managing customer orders.
Having a menu with items and their prices is necessary.
As customers make their orders, the items and their prices are recorded in variables.
The total cost of the order is updated as each item is added to the order.
Getting input from the user to create the order is done with a loop.
Print out the order details and the total cost at the end.
To make the system more advanced, additional features could be added such as discounts or payment processing.

Editor's note: Asked it to do the last part instead of doing it manually.

This post has been edited by angch: Feb 21 2023, 12:02 PM
TSWongGei
post Feb 21 2023, 10:27 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(angch @ Feb 20 2023, 07:06 PM)
CODE

# Define the menu with prices
menu = {
   "Hamburger": 5.00,
   "Cheeseburger": 6.00,
   "Hot Dog": 4.00,
   "French Fries": 3.00,
   "Soda": 1.50,
   "Water": 1.00
}

# Initialize variables
order_total = 0.00
order_items = []

# Take customer order
while True:
   item = input("Please enter an item name (or 'done' to complete the order): ")
   if item.lower() == "done":
       break
   elif item in menu:
       order_items.append(item)
       order_total += menu[item]
       print(f"{item} added to order (total: ${order_total:.2f})")
   else:
       print("Sorry, that item is not on the menu.")

# Print order details
print("\nOrder Summary:")
for item in order_items:
   print(f"- {item}: ${menu[item]:.2f}")
print(f"Total: ${order_total:.2f}")


Chances are we can write the code
Here that we can ignore some of the data
At the image just because
There isn't much point for me to
Grab the tiny pixels of information my
Poor eyesight can read.
Text that can be copied and pasted is much better.
*
Reason:
Pros:
Data and Algorithm are separated. Data can be changed with out affecting the algorithm.
Con:
Still need to be compiled and deployed if any changes.

From my opinions,
This should be a Junior Programmer work.
silverhawk
post Feb 21 2023, 10:30 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


Its not as simple as it looks

The moment you have sets, things get really complicated. Are the sets only bundles? Do they have conditional requirements? are set values fixed or percentage off? coupon and voucher rules, etc
TSWongGei
post Feb 21 2023, 11:13 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Feb 21 2023, 10:30 AM)
Its not as simple as it looks

The moment you have sets, things get really complicated. Are the sets only bundles? Do they have conditional requirements? are set values fixed or percentage off? coupon and voucher rules, etc
*
Good questions. rclxms.gif

That's the questions that a senior programmer should ask before he/she even start coding.
flashang
post Feb 21 2023, 12:03 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


You might need to think about how to control if sold out,
which required inventory control.

For each order of "YOU TIAO"
ala carte / SET A / SET B / SET C / SET E
have to deduct the stock balance of product "YOU TIAO"

So your MENU / SET setup need to link to products.

Some product may have "optional", such as
Soya bean : "Cold / Hot", "no sugar", "standard", "less sugar", "extra sugar".
Porridge : "no spring onion", "extra egg".

Some products may have to do dispose before closing of the day.

smile.gif


cassian948
post Feb 21 2023, 12:11 PM

Enthusiast
*****
Junior Member
931 posts

Joined: Jan 2017
From: Kuala Lumpur
So, unless the customer explicitly orders a set, each item should charge individually and not automatically discounted as a set?
TSWongGei
post Feb 21 2023, 12:24 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(flashang @ Feb 21 2023, 12:03 PM)
You might need to think about how to control if sold out,
which required inventory control.

For each order of "YOU TIAO"
ala carte / SET A / SET B / SET C / SET E
have to deduct the stock balance of product "YOU TIAO"

So your MENU / SET setup need to link to products.

Some product may have "optional", such as
Soya bean : "Cold / Hot", "no sugar", "standard", "less sugar", "extra sugar".
Porridge : "no spring onion", "extra egg".

Some products may have to do dispose before closing of the day.

smile.gif
*
The question are mostly out of scoop.
Even the hot/cold, no sugar and etc wont affect the calculation of the price.

This is just a program that calculate the price of an order, not inventory control system.


TSWongGei
post Feb 21 2023, 12:30 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(cassian948 @ Feb 21 2023, 12:11 PM)
So, unless the customer explicitly orders a set, each item should charge individually and not automatically discounted as a set?
*
This is a very good question.
Imagine you are a customer, how you would like the system to have?
If you just like to have a You Tiao and your friend just like to have a Tau Fu Fa, how will you order?

I will qualify the question as a question that a junior programmer will ask cause it will still need to recompile the program every time changes happen?
flashang
post Feb 21 2023, 12:45 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Feb 21 2023, 12:24 PM)
The question are mostly out of scoop.
Even the hot/cold, no sugar and etc wont affect the calculation of the price.

This is just a program that calculate the price of an order, not inventory control system.
*
Indeed, hot/cold, standard / large do not affect the price if using different product code.

Only add-on (extra egg, extra kaya) will affect the price.
Of course you could use side-order with different product code.

But the ordering UI / form and the preview/receipt might need to re-design.

P/S :
To have a better view of how good the ordering system is,
may be go to some cafe / shop / mcd,
take picture of their ordering slip / online order website / order kiosk,
and go through the whole process.

smile.gif



This post has been edited by flashang: Feb 21 2023, 01:01 PM
TSWongGei
post Feb 21 2023, 04:36 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Feb 20 2023, 12:29 PM)
user posted image

Requirement,

Create a simple POS system that take in customer order and calculates the total amount of the order.

This seems like a simple question that suits 1st assignment of the programming language class.

Let see how the Newbie, Junior Programmer, Senior Programmers' work.

And discuss why the program classified as such (N,J,S)
*
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment




Attached File(s)
Attached File  newbie.gz ( 1.04k ) Number of downloads: 13
FlierMate4
post Feb 21 2023, 04:52 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(WongGei @ Feb 21 2023, 04:36 PM)
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment
*
The C++ code is clean and straightforward, looks like it was written by a teacher, not by student. hmm.gif

user posted image

I took note that the total price is printed only after choosing "z" (exit).


This post has been edited by FlierMate4: Feb 21 2023, 08:23 PM
flashang
post Feb 21 2023, 11:32 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Feb 21 2023, 04:36 PM)
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment
*
How many marks you could get is depends on marking scheme,
and this is based on what are the expected work.

e.g.

working code : 50% (every major bug -10%)
use object : 15%
use inheritance : 10%
use struct : 10%
use switch case : 5%
load data from file, not variables : 10%

Note : program with bugs may have higher marks if more criteria are met.

Total : 100%

Grade :
0~20% F
21~40% E
41~49% D
50~70% C
71~80% B
81~90% A
91~100% A+

These are just some assumption.

smile.gif



This post has been edited by flashang: Feb 21 2023, 11:41 PM
TSWongGei
post Feb 22 2023, 10:52 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(flashang @ Feb 21 2023, 11:32 PM)
How many marks you could get is depends on marking scheme,
and this is based on what are the expected work.

e.g.

working code : 50% (every major bug -10%)
use object : 15%
use inheritance : 10%
use struct : 10%
use switch case : 5%
load data from file, not variables : 10%

Note : program with bugs may have higher marks if more criteria are met.

Total : 100%

Grade :
0~20% F
21~40% E
41~49% D
50~70% C
71~80% B
81~90% A
91~100% A+

These are just some assumption.

smile.gif
*
whistling.gif
TSWongGei
post Feb 23 2023, 04:46 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Feb 21 2023, 04:36 PM)
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment
*
After study for some time, a newbie learn how to separates data with algorithm and make the program more easy to change.

Still, need to recompile and deploy program every time changes involved.


Attached File(s)
Attached File  junior.gz ( 1.38k ) Number of downloads: 10
flashang
post Feb 23 2023, 11:16 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Feb 23 2023, 04:46 PM)
After study for some time, a newbie learn how to separates data with algorithm and make the program more easy to change.

Still, need to recompile and deploy program every time changes involved.
*
You could use "alacarte" as "Set" with only 1 item.

smile.gif


silverhawk
post Feb 23 2023, 11:20 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(WongGei @ Feb 21 2023, 12:30 PM)
This is a very good question.
Imagine you are a customer, how you would like the system to have?
If you just like to have a You Tiao and your friend just like to have a  Tau Fu Fa, how will you order?

I will qualify the question as a question that a junior programmer will ask cause it will still need to recompile the program every time changes happen?
*
Its a good question, not necessarily a "junior" question.

The one who defines that system is not the customer, but the company. From user perspective, they don't really care. Many POS still can't do auto sets, and in the past this is how some workers used to cheat money from the customer and company. They would quickly switch ala carte and set pricing so customer pays higher but they record as set in the system and pocket the difference. .
TSWongGei
post Feb 24 2023, 01:29 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Feb 23 2023, 11:20 PM)
Its a good question, not necessarily a "junior" question.

The one who defines that system is not the customer, but the company. From user perspective, they don't really care. Many POS still can't do auto sets, and in the past this is how some workers used to cheat money from the customer and company. They would quickly switch ala carte and set pricing so customer pays higher but they record as set in the system and pocket the difference. .
*
This is just an application. Depends on who and how it is used.
I used the above menu as a example is not a coincidentally. I was at one of the outlet last week. Was placing the order of a soya bean because I was thirty. Then I watch the cashier key in my order. Then I feel like a bit of hungry, so, I add-on a you tiao in my order.
The cashier just press one button (or move his hand once) to add my "you tiao" order. And I ask how much, surprisingly he quote me the set price instead of 2 alarcart order, without erasing my previous order and re-key in (No more moving hand nor fingers). It means the system can automatic give you offer of the set price when your alarcart meet the set requirement.
That inspire me to create a thread and discuss about this.

So far I haven't see any "codemaster" that can come out with the algorithm to do that.

TSWongGei
post Feb 24 2023, 01:39 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Feb 23 2023, 11:20 PM)

The one who defines that system is not the customer, but the company. From user perspective, they don't really care. Many POS still can't do auto sets, and in the past this is how some workers used to cheat money from the customer and company. They would quickly switch ala carte and set pricing so customer pays higher but they record as set in the system and pocket the difference. .
*
To further answer your consideration, may be a POS system doesn't care if it is charged as a la cart or set. But the same algorithm can be used by a courier company or ship cargo. Imagine the price is a volume that require to fit an item (alacarte). There are only certain type of boxes (set). How many boxes are needed how to maximized the space utilization. The shipment company will pay you tons of money to come out with a program that can do that.
angch
post Feb 24 2023, 01:47 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(WongGei @ Feb 24 2023, 01:29 PM)
It means the system can automatic give you offer of the set price when your alarcart meet the set requirement.
That inspire me to create a thread and discuss about this.

So far I haven't see any "codemaster" that can come out with the algorithm  to do that.
*
Not too hard, just need a combinatorial optimization solver after every addition of single orders.

A variation on: https://gist.github.com/angch/287342ca84f0ede4146d

Edit: I'll hack on it when I've time, but not anytime soon. Bookmarked.

This post has been edited by angch: Feb 24 2023, 01:56 PM
SUSifourtos
post Feb 24 2023, 01:50 PM

Look at all my stars!!
*******
Senior Member
2,256 posts

Joined: Feb 2012




A senior would not plan coding in 1st Place.
never.


You need to design a relational database 1st.
then you build you logic


The most complicated part would be

= Product
= Ordered Item then Order
= Receipt


Product DB = available time? Avalbility? Linked Modifer Item, Linked Add On Item, Price, Desc, Linked Package

Linked Package = Linked Product, Set Name, ( and its price modifier )
Linked Modifier = example, less sweet, no onion etc ( and its price modifier )
Linked Addon = Add telur ( and its price modifier )

-----

Ordered Item DB = Linked Product, modifier, quantity, takeaway?, addon, discount?, order status, order time, user id, linked Menu/store (if franchise)
Order = Linked Ordered Item, Subtotal, discount, tax, service charges, table ....

-----

Receipt = Linked Order, payment type, store, staff received payment, discount......



Logic is entry level, it just a presentation/manipulation of Database.

A Lightweight, query optimized, scalable, insightful Database Design is the Key of any Mass Production Level Software.

silverhawk
post Feb 24 2023, 02:14 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(WongGei @ Feb 24 2023, 01:29 PM)
That inspire me to create a thread and discuss about this.

So far I haven't see any "codemaster" that can come out with the algorithm  to do that.
*
Errr... its not that hard.

I've built backends that do stuff like that. I had a "promotion module" which basically allowed the company to create promotion rules. Like if you wanted to create a set (bundle). You would say if got X and Y item, then the price is $Z, or can set it is a fixed deduction, or even percentage off or even another item.

The promotions have to be weighted, so that some promotions take precendence over others. Then have to handle things which promotions can be used together and which can't. Like ordering bundles and get free shipping over $A amount is typically allowed. But using coupons on discounted items isn't.

QUOTE(WongGei @ Feb 24 2023, 01:39 PM)
To further answer your consideration, may be a POS system doesn't care if it is charged as a la cart or set. But the same algorithm can be used by a courier company or ship cargo. Imagine the price is a volume that require to fit an item (alacarte). There are only certain type of boxes (set). How many boxes are needed how to maximized the space utilization. The shipment company will pay you tons of money to come out with a program that can do that.
*
Courier companies already have stuff like that. Its a solved problem. Google for it, you'll find solutions.

QUOTE(ifourtos @ Feb 24 2023, 01:50 PM)
A senior would not plan coding in 1st Place.
never.
You need to design a relational database 1st.
then you build you logic
*
That's not true.

If you have to build your database first, then you have already very tightly coupled your database design to your code. Ideally, your code should not care how the database is design, it just needs to receive the correct inputs.

What data is required can be mocked first. This allows you to iterate through your code faster and find flaws in your assumptions. Then you decide where you want to store the data and how. Could be as simple as a CSV, relational DB like MySQL or NoSQL like mongoDB. Regardless, the core logic of your code should not change and ideally all you have to do to is write the adapters for the DB you plan to use.
angch
post Feb 24 2023, 08:03 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(silverhawk @ Feb 24 2023, 02:14 PM)
Errr... its not that hard.

I've built backends that do stuff like that. I had a "promotion module" which basically allowed the company to create promotion rules. Like if you wanted to create a set (bundle). You would say if got X and Y item, then the price is $Z, or can set it is a fixed deduction, or even percentage off or even another item.

The promotions have to be weighted, so that some promotions take precendence over others. Then have to handle things which promotions can be used together and which can't. Like ordering bundles and get free shipping over $A amount is typically allowed. But using coupons on discounted items isn't.
Courier companies already have stuff like that. Its a solved problem. Google for it, you'll find solutions.
That's not true.

If you have to build your database first, then you have already very tightly coupled your database design to your code. Ideally, your code should not care how the database is design, it just needs to receive the correct inputs.

What data is required can be mocked first. This allows you to iterate through your code faster and find flaws in your assumptions. Then you decide where you want to store the data and how. Could be as simple as a CSV, relational DB like MySQL or NoSQL like mongoDB. Regardless, the core logic of your code should not change and ideally all you have to do to is write the adapters for the DB you plan to use.
*
Heh, some business requirements may be counter intuitive. e.g.

1. Burger RM8
2. Fries RM3
3. Drink RM3
Set A: Burger+Fries+Drink = RM10

Someone who just order burger and drink is actually better off getting set A, which contained fries they don't want.

So, should the optimizer auto add a Fries to the person's order to get Set A? Or should the system leave it to the cashier?

Or can the system handle a Set with optional components? e.g. Order Set A, minus Fries?

Anyone tried ordering kopi-o kosong tanpa kopi before? Might be cheaper than their mineral water...


This post has been edited by angch: Feb 24 2023, 08:08 PM
silverhawk
post Feb 24 2023, 11:53 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(angch @ Feb 24 2023, 08:03 PM)
Heh, some business requirements may be counter intuitive. e.g.

1. Burger RM8
2. Fries RM3
3. Drink RM3
Set A: Burger+Fries+Drink = RM10

Someone who just order burger and drink is actually better off getting set A, which contained fries they don't want.

So, should the optimizer auto add a Fries to the person's order to get Set A? Or should the system leave it to the cashier?

Or can the system handle a Set with optional components? e.g. Order Set A, minus Fries?

Anyone tried ordering kopi-o kosong tanpa kopi before? Might be cheaper than their mineral water...
*
The rules are not that weird actually.

If you consider kitchen operation and inventory you would actually save money if more people bought sets, even though your profit margin might seem higher if they bought ala-carte separately.

The thing is, the pricing engine is not an optimizer. Its purpose is not to give you the cheapest thing, its purpose is for the company to push their promotions to you. What we did was detect if a bundle condition is met, we prompt the user with an option to convert to bundle to save $x dollars. The service was purely online based, so no cashier, but the same interface could be implemented on cashier front if done as POS.


TSWongGei
post Feb 25 2023, 10:53 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(angch @ Feb 24 2023, 08:03 PM)
Heh, some business requirements may be counter intuitive. e.g.

1. Burger RM8
2. Fries RM3
3. Drink RM3
Set A: Burger+Fries+Drink = RM10

Someone who just order burger and drink is actually better off getting set A, which contained fries they don't want.

So, should the optimizer auto add a Fries to the person's order to get Set A? Or should the system leave it to the cashier?

Or can the system handle a Set with optional components? e.g. Order Set A, minus Fries?

Anyone tried ordering kopi-o kosong tanpa kopi before? Might be cheaper than their mineral water...
*
Nice feature to have.

Let consider how people reaction.

1.) Junior Programmer :- ha? Like this also can ah ...how to do ah?
2.) Senior Programmer :- Wah lau Eh ... siao meh ... who is going to use it ... ok lah ....not that hard.
3.) Project Manager :- Em ... nice feather, but how long to implement and probably noone will use it
4.) System Architect :- Em ... we should build the framework to enable this
5.) IT firm boss :- This one may be we need it. But not at this moment
6.) Client :- Oh ...interesting. I can use it
7.) Environmentalist :- It's a waste of resource, let boycott the shop.

So, which level are you in?

This post has been edited by WongGei: Feb 25 2023, 10:56 AM
flashang
post Feb 26 2023, 12:29 AM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(ifourtos @ Feb 24 2023, 01:50 PM)
A senior would not plan coding in 1st Place.
never.
You need to design a relational database 1st.
then you build you logic
The most complicated part would be

  = Product
  = Ordered Item then Order
  = Receipt
Product DB = available time? Avalbility? Linked Modifer Item, Linked Add On Item, Price, Desc, Linked Package

Linked Package = Linked Product, Set Name,  ( and its price modifier )
Linked Modifier = example, less sweet, no onion etc ( and its price modifier )
Linked Addon = Add telur  ( and its price modifier )

-----

Ordered Item DB = Linked Product, modifier, quantity, takeaway?, addon, discount?, order status, order time, user id, linked Menu/store (if franchise)
Order = Linked Ordered Item, Subtotal, discount, tax, service charges, table ....

-----

Receipt = Linked Order, payment type, store, staff received payment, discount......
Logic is entry level, it just a presentation/manipulation of Database.

A Lightweight, query optimized, scalable, insightful Database Design is the Key of any Mass Production Level Software.
*
Although it's old school, sdlc still valid when develop a system.
You should do planning and analysis before design.

smile.gif


kingkingyyk
post Feb 26 2023, 06:05 PM

10k Club
Group Icon
Elite
15,694 posts

Joined: Mar 2008
It is quite subjective whether to implement the optimizer or not.

- Customer might be ordering for few person and going to split the bill later on.
- Company decided to go evil to earn more money by hiding the promotion, so even the customer ordered the item as found in the set, it still charge as single item. brows.gif

The requirements definitely need some static testing.

This post has been edited by kingkingyyk: Feb 26 2023, 06:05 PM
TSWongGei
post Feb 27 2023, 10:41 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(kingkingyyk @ Feb 26 2023, 06:05 PM)
It is quite subjective whether to implement the optimizer or not.

- Customer might be ordering for few person and going to split the bill later on.
- Company decided to go evil to earn more money by hiding the promotion, so even the customer ordered the item as found in the set, it still charge as single item. brows.gif

The requirements definitely need some static testing.
*
This are true statement and often wrongly interpreted, either by cashier or staff on the ground.
First of all, noone forced to have a promotion except the owner of the business. So, the owner already make the calculation and find that it is worth, then only the promotion is being launched.
Client will definitely welcome the promotion because they can pay less for more.
The only person that doesn't like the promotion might be the middle and lower management of the business, because they are not the direct beneficial of the campaign.

As a programmer, we should always/try to enable the business owner to earn more income.

How often we go to the bank or other business and we are forced to do things in wired way. Just like the credit/debit card terminal in GSC, that need to tap two times to make payment. Anyone notice that?

For me, the optimizer is not a must, but good to have feather.

As a programmer, no matter this feather will be in/out from the current project, it is good to know that there are something out there that need to be done, either by yourself or someone who will take over your position. If you have time, do make some planning or create a program that can be modified to have that.


FlierMate4
post Feb 27 2023, 04:38 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(WongGei @ Feb 23 2023, 04:46 PM)
After study for some time, a newbie learn how to separates data with algorithm and make the program more easy to change.

Still, need to recompile and deploy program every time changes involved.
*
Unlike your newbie.cpp, the junior.cpp cannot run by Dev-C++, it reported errors:
CODE
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"1", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"2", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"4", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"1", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"2", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"4", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'


However, it runs successfully using Visual Studio.
So it must be something to do with configuration in Dev-C++.


angch
post Feb 27 2023, 05:41 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(FlierMate4 @ Feb 27 2023, 04:38 PM)
Unlike your newbie.cpp, the junior.cpp cannot run by Dev-C++, it reported errors:
CODE
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"1", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"2", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"4", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"1", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"2", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"4", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'


However, it runs successfully using Visual Studio.
So it must be something to do with configuration in Dev-C++.
*
You need to use C++11. e.g. using GCC,
CODE
g++ -std=c++11 junior.cpp


This post has been edited by angch: Feb 27 2023, 05:43 PM
TSWongGei
post Feb 27 2023, 05:46 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(FlierMate4 @ Feb 27 2023, 04:38 PM)
Unlike your newbie.cpp, the junior.cpp cannot run by Dev-C++, it reported errors:
CODE
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"1", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"2", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"4", "3", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"1", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"2", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
106 1 C:\Users\~User~\Downloads\junior.cpp [Error] could not convert '{"4", "3", "6", "7"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'


However, it runs successfully using Visual Studio.
So it must be something to do with configuration in Dev-C++.
*
compiler too old. Need C++11 or newer compiler. Try to set the option of your compiler to -std=c++11

P.S. C++11 is a C++ standard that is released at 2011, which is 12 years ago. The latest standard is C++20

user posted image
FlierMate4
post Feb 27 2023, 06:09 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(angch @ Feb 27 2023, 05:41 PM)
You need to use C++11. e.g. using GCC,
CODE
g++ -std=c++11 junior.cpp

*
QUOTE(WongGei @ Feb 27 2023, 05:46 PM)
compiler too old. Need C++11 or newer compiler. Try to set the option of your compiler to -std=c++11

P.S. C++11 is a C++ standard that is released at 2011, which is 12 years ago. The latest standard is C++20
*
Yes, the Dev-C++ is working now after adding "-std=c++11" in compiler option.

Thanks.
TSWongGei
post Feb 28 2023, 09:58 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
Finally, refreshed my c++ skill to current c++ standard.
Amazed with the ever revolving c++ standard rclxms.gif




Attached File(s)
Attached File  senior.gz ( 10k ) Number of downloads: 8
TSWongGei
post Mar 1 2023, 01:11 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Feb 28 2023, 09:58 PM)
Finally, refreshed my c++ skill to current c++ standard.
Amazed with the ever revolving c++ standard rclxms.gif
*
I classify it as a work of senior programmer based on the following criteria

1.) menu and order are read in from file instead of key in manually, this make the program easy to process big amount of data.
2.) Separating static data (menu) storage with program binary make the program much more easy to adopt changes. Changes in menu, that can happen time to time doesn't require re-compile of binary files.
silverhawk
post Mar 1 2023, 09:45 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(WongGei @ Mar 1 2023, 01:11 PM)
I classify it as a work of senior programmer based on the following criteria

1.)  menu and order are read in from file instead of key in manually, this make the program easy to process big amount of data.
2.)  Separating static data (menu) storage with program binary make the program much more easy to adopt changes. Changes in menu, that can happen time to time doesn't require re-compile of binary files.
*
To me that is still junior laugh.gif

You cannot do that level, you're still a student.
flashang
post Mar 1 2023, 10:27 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Mar 1 2023, 01:11 PM)
I classify it as a work of senior programmer based on the following criteria

1.)  menu and order are read in from file instead of key in manually, this make the program easy to process big amount of data.
2.)  Separating static data (menu) storage with program binary make the program much more easy to adopt changes. Changes in menu, that can happen time to time doesn't require re-compile of binary files.
*
IMHO,
The menu.csv file do not have row header, which make changes confuse.

A complete project might include presentation or demonstrate how it work and what are the expected results.

By the way, does anyone test the program to see if the program running with a "user understand" way ?
Will you create some user manual to let people know how to use the senior version ?

smile.gif


TSWongGei
post Mar 2 2023, 09:31 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(flashang @ Mar 1 2023, 10:27 PM)
IMHO,
The menu.csv file do not have row header, which make changes confuse.

A complete project might include presentation or demonstrate how it work and what are the expected results.

By the way, does anyone test the program to see if the program running with a "user understand" way ?
Will you create some user manual to let people know how to use the senior version ?

smile.gif
*
laugh.gif Its hard for a guys like you to understand. .....

1.) The menu.csv wont be edited by human. Even though it can be done easily.
2.) This is a demo program to showcase programming skill, not project management , presentation skill
3.) I test it and it works. Can't you compile the source? If you are unable to compile the program, learn how to compile and run it first, like @FlierMate4
4.) Nope unless you pay me for that. The source is already open. Its an open source version not spoon feeding version.

This post has been edited by WongGei: Mar 2 2023, 09:32 AM
TSWongGei
post Mar 2 2023, 09:35 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Mar 1 2023, 09:45 PM)
To me that is still junior laugh.gif

You cannot do that level, you're still a student.
*
Indeed, a lot of our FYP student code is much worse than that.
FlierMate4
post Mar 2 2023, 01:43 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(flashang @ Mar 1 2023, 10:27 PM)
By the way, does anyone test the program to see if the program running with a "user understand" way ?
*
Below is the output running using the default order.txt.
user posted image

The predefined order is A1, D:
A1:
CODE
A1,Set A - Butterfly Bun + Porridge,3.2,1,7


CODE
1,Butterfly Bun,1.0,1
7,Dry Scallop Porridge,2.5,7


D:
CODE
D,Set D - Tao Foo Far + Soya Bean,3.9,3,6


CODE
3,Soya Bean,2.0,3
6,Tao Foo Far,2.2,6


The total price should be RM 7.10, but I see RM 6.90.... The C++ code crafted by WongGei is beyond my level, since junior.cpp, I am not able to fully understand his C++ code, as my level is newbie.cpp. brows.gif


FlierMate4
post Mar 2 2023, 01:45 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
I run senior.cpp with Visual Studio 2022, no problem.

But again, not able to compile and run senior.cpp using Dev-C++, it complains:

CODE
3755 14 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\stl_algo.h [Error] invalid use of 'auto'


And point to file in 'std_algo.h'.

user posted image

I use the same compiler option for c++11.

Thanks for any help.



This post has been edited by FlierMate4: Mar 2 2023, 01:47 PM
TSWongGei
post Mar 2 2023, 01:55 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(FlierMate4 @ Mar 2 2023, 01:45 PM)
I run senior.cpp with Visual Studio 2022, no problem.

But again, not able to compile and run senior.cpp using Dev-C++, it complains:

CODE
3755 14 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\stl_algo.h [Error] invalid use of 'auto'


And point to file in 'std_algo.h'.

user posted image

I use the same compiler option for c++11.

Thanks for any help.
*
try -std=c++20
FlierMate4
post Mar 2 2023, 02:00 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(FlierMate4 @ Mar 2 2023, 01:43 PM)
The total price should be RM 7.10, but I see RM 6.90....
*
Found it, this:
CODE
E1,Set E - Butterfly Bun + Porridge + Tao Foo Far + Soya Bean,6.9,1,3,6,7

FlierMate4
post Mar 2 2023, 02:02 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(WongGei @ Mar 2 2023, 01:55 PM)
try -std=c++20
*
Maybe I will just stick to Visual Studio 2022, as Dev-C++ returns an error:
CODE
C:\Users\~User~\Downloads\g++.exe [Error] unrecognized command line option '-std=c++20'

TSWongGei
post Mar 2 2023, 02:04 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(FlierMate4 @ Mar 2 2023, 01:43 PM)
Below is the output running using the default order.txt.
user posted image

The predefined order is A1, D:
A1:
CODE
A1,Set A - Butterfly Bun + Porridge,3.2,1,7


CODE
1,Butterfly Bun,1.0,1
7,Dry Scallop Porridge,2.5,7


D:
CODE
D,Set D - Tao Foo Far + Soya Bean,3.9,3,6


CODE
3,Soya Bean,2.0,3
6,Tao Foo Far,2.2,6


The total price should be RM 7.10, but I see RM 6.90.... The C++ code crafted by WongGei is beyond my level, since junior.cpp, I am not able to fully understand his C++ code, as my level is newbie.cpp.  brows.gif
*
Updated the output to make it easier to understand how the sum being calculated.

Price of A1 + D = 3.2 + 3.9 = 7.1
But 1,7,3,6 can form a set E1, which the price is 6.9

user posted image

This post has been edited by WongGei: Mar 2 2023, 02:07 PM


Attached File(s)
Attached File  senior.gz ( 1.95k ) Number of downloads: 4
flashang
post Mar 2 2023, 07:23 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Mar 2 2023, 09:31 AM)
laugh.gif Its hard for a guys like you to understand. .....

1.) The menu.csv wont be edited by human. Even though it can be done easily.
2.) This is a demo program to showcase programming skill, not project management , presentation skill
3.) I test it and it works. Can't you compile the source? If you are unable to compile the program, learn how to compile and run it first, like @FlierMate4
4.) Nope unless you pay me for that. The source is already open. Its an open source version not spoon feeding version.
*
It might be too harsh if speak directly.
don't take it too serious as this is only personal opinion.

smile.gif

This are what tested :

CODE

Case 1 : menu.csv and order.txt exists :

A1
D
====
7
1
6
3
====
6.9



Case 2 : only order.txt exists :

A1
D
====
Error in order file, please check
0



Case 3 : only menu.cs exist :
Case 4 : both menu.cs & order.txt missing :

====
====
0





The "senior" version read data from menu.csv & order.txt, do some matching and display total amount.

What was missing ?

QUOTE
Requirement,
Create a simple POS system that take in customer order and calculates the total amount of the order.
* it does not "take in customer order" -- which was done in "newbie" & "junior" version.
* it only shows numbers and code, no product name -- which was done in "newbie" & "junior" version.
* the error message "Error in order file, please check" misleading user to search for wrong direction. it should be "menu.csv error or not found"

If "The menu.csv wont be edited by human",
are the "order.txt" should be edit by user ?
because this do not accept user to key in order.

smile.gif


iammyself
post Mar 2 2023, 08:49 PM

Getting Started
**
Junior Member
238 posts

Joined: May 2011
I've been watching this thread for a while. This is satirical right?

All the discussion about "hey if I do it this way I'm a senior" etc. is just unproductive and honestly a little bit childish.

At the end of the day, it's about project requirements.

If your requirement is introductory university level, no senior or staff or coding ninja will set up a POS application with 100% test coverage, backed by a cluster of database instances etc.

Go ahead if you just want to have fun building a toy POS system that uses the terminal for input. But stop with the labeling nonsense please, it's childish.
angch
post Mar 2 2023, 08:54 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(iammyself @ Mar 2 2023, 08:49 PM)
I've been watching this thread for a while. This is satirical right?

All the discussion about "hey if I do it this way I'm a senior" etc. is just unproductive and honestly a little bit childish.

At the end of the day, it's about project requirements.

If your requirement is introductory university level, no senior or staff or coding ninja will set up a POS application with 100% test coverage, backed by a cluster of database instances etc.

Go ahead if you just want to have fun building a toy POS system that uses the terminal for input. But stop with the labeling nonsense please, it's childish.
*
smile.gif Let them^Wus have their^Wour fun. Let's not gate keep, this group is quiet enough already. At least there's code being written, shared and discussed.

This post has been edited by angch: Mar 2 2023, 08:54 PM
15cm
post Mar 2 2023, 11:43 PM

Casual
***
Junior Member
423 posts

Joined: Apr 2022
can i join the fun? my c is pretty shitty
silverhawk
post Mar 3 2023, 12:04 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(iammyself @ Mar 2 2023, 08:49 PM)
I've been watching this thread for a while. This is satirical right?

All the discussion about "hey if I do it this way I'm a senior" etc. is just unproductive and honestly a little bit childish.

At the end of the day, it's about project requirements.

If your requirement is introductory university level, no senior or staff or coding ninja will set up a POS application with 100% test coverage, backed by a cluster of database instances etc.

Go ahead if you just want to have fun building a toy POS system that uses the terminal for input. But stop with the labeling nonsense please, it's childish.
*
He's just having fun creating different levels of complexity.

Yes the labelling is inane, but like angch said code is being written, people are having fun.
silverhawk
post Mar 3 2023, 12:05 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(15cm @ Mar 2 2023, 11:43 PM)
can i join the fun? my c is pretty shitty
*
From you I'd expect it to be in a JS framework laugh.gif
TSWongGei
post Mar 3 2023, 11:09 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(flashang @ Mar 2 2023, 07:23 PM)
It might be too harsh if speak directly.
don't take it too serious as this is only personal opinion.

smile.gif 

This are what tested :

CODE

Case 1 : menu.csv and order.txt exists :

A1
D
====
7
1
6
3
====
6.9
Case 2 : only order.txt exists :

A1
D
====
Error in order file, please check
0
Case 3 : only menu.cs exist :
Case 4 : both menu.cs & order.txt missing :

====
====
0


The "senior" version read data from menu.csv & order.txt, do some matching and display total amount.

What was missing ?
* it does not "take in customer order" -- which was done in "newbie" & "junior" version.
* it only shows numbers and code, no product name -- which was done in "newbie" & "junior" version.
* the error message "Error in order file, please check" misleading user to search for wrong direction. it should be "menu.csv error or not found"

If "The menu.csv wont be edited by human",
are the "order.txt" should be edit by user ?
because this do not accept user to key in order.

smile.gif
*
As I said, you will never undestand the work of programmer. Why reinvent the wheel?
If there is a front-end to write the input / output work for you. Why do you need to duplicates the work?
A junior can write the program to generate orders.txt and update the menu.csv accordingly. A senior will write a program to do the calculation. Don't waste a senior time to do things that can be done by a junior.
Another reason why it has been done this way is I can ask ChatGPT to create a program to take in order and save it into the order.txt file format for me. Then I just have to write a program to do the calculation.



This post has been edited by WongGei: Mar 3 2023, 03:34 PM
TSWongGei
post Mar 3 2023, 11:11 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(15cm @ Mar 2 2023, 11:43 PM)
can i join the fun? my c is pretty shitty
*
You are most welcomed. I purposely leave out the language category so that more programmer with different language skill can showcase their work.

This post has been edited by WongGei: Mar 3 2023, 11:28 AM
TSWongGei
post Mar 3 2023, 11:27 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(iammyself @ Mar 2 2023, 08:49 PM)
I've been watching this thread for a while. This is satirical right?

All the discussion about "hey if I do it this way I'm a senior" etc. is just unproductive and honestly a little bit childish.

At the end of the day, it's about project requirements.

If your requirement is introductory university level, no senior or staff or coding ninja will set up a POS application with 100% test coverage, backed by a cluster of database instances etc.

Go ahead if you just want to have fun building a toy POS system that uses the terminal for input. But stop with the labeling nonsense please, it's childish.
*
Sorry for the childish act.
A senior programmer can always code like a junior programmer depends on the requirement. But its hard for a junior / newbie programmer to code like a senior.

Yes, in real world, program is all about budget and company constraint instead of the programmer skill.
With 1 day budget, I will write like a junior cause no point invest in something more than what you can get. At the end of the day, we still need to eat like others.
But as a programmer, I will always try to figure out a better way to improve the same piece of code/program to improve my skill.

As mentioned earlier, I started this thread is because I was impressed and would like to see how long to implement the optimization for price calculation. Take the opportunity to brush up my C++ skill to the recent standard.

Since the "Codemaster" is very quite recently, its good to know that many are still following the forum.

I encounter numerous situation where system can be done better and it is not. At the end, end user (client, business user) is the one who need to do extra works because the system are not designed to adopt the changes fast enough.

This post has been edited by WongGei: Mar 3 2023, 11:43 AM
TSWongGei
post Mar 3 2023, 01:07 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Mar 2 2023, 02:04 PM)
Updated the output to make it easier to understand how the sum being calculated.

Price of A1 + D = 3.2 + 3.9 = 7.1
But 1,7,3,6 can form a set E1, which the price is 6.9

user posted image
*
As a programmer, my though won't stop after I delivered the code.
There's always room to grow. -Scott
After I wrote the program and menu.csv, which it fulfill the purpose of the program and ordering system.
What if there are more types of campaign that the shop like to do?

Its a simple requirement and we can see that in everydays life.

Buy 4 You Tiao free 1 or Buy 5 You Tiao get 20% discount.

If you are the company that support the program, what would you do?

First, You will tell the business owner, easy ja, just add new code into the menu that have 2,2,2,2,2 .....
Then the business owner will says , "OK, what about Butterfly Bun and Friend Red Bean Bun?" .......
Then you will answer "No problem, add another 1,1,1,1,1 and 4,4,4,4,4 into the menu.csv ..."
OK. Still cool, right ....

So, what is the potential problem here?

This post has been edited by WongGei: Mar 3 2023, 01:08 PM
flashang
post Mar 3 2023, 10:59 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Mar 3 2023, 11:09 AM)
As I said, you will never undestand the work of programmer. Why reinvent the wheel?
If there is a front-end to write the input / output work for you. Why do you need to duplicates the work?
A junior can write the program to generate orders.txt and update the menu.csv accordingly. A senior will write a program to do the calculation. Don't waste a senior time to do things that can be done by a junior.
Another reason why it has been done this way is I can ask ChatGPT to create a program to take in order and save it into the order.txt file format for me. Then I just have to write a program to do the calculation.
*
Some people might think a good programmer is to write some show off technique codes.

Some other people believe this :
QUOTE
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”

― Martin Fowler
A good code should be clear to read and easy to understand,
even for junior programmer (for handover),
or you can just recall within a seconds after many years later to upgrade the software.

Of course comments could helps,
but a good design structure, format make less effort to understand.

For someone who do not have enough basic skill / knowledge,
Copy paste the code from internet does not means they can make a working software or improve it.

smile.gif

A note for everyone : You may forgive those people who don't know you. biggrin.gif tongue.gif


TSWongGei
post Mar 4 2023, 04:37 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Mar 3 2023, 01:07 PM)
As a programmer, my though won't stop after I delivered the code.
There's always room to grow. -Scott
After I wrote the program and menu.csv, which it fulfill the purpose of the program and ordering system.
What if there are more types of campaign that the shop like to do?

Its a simple requirement and we can see that in everydays life.

Buy 4 You Tiao free 1 or Buy 5 You Tiao get 20% discount.

If you are the company that support the program, what would you do?

First,  You will tell the business owner, easy ja, just add new code into the menu that have 2,2,2,2,2  .....
Then the business owner will says , "OK, what about Butterfly Bun and Friend Red Bean Bun?" .......
Then you will answer "No problem, add another 1,1,1,1,1 and 4,4,4,4,4 into the menu.csv ..."
OK. Still cool, right ....

So, what is the potential problem here?
*
A senior programmer might not be a good programmer and a junior programmer might not be a bad programmer.
As we see in Big Bang Theory, high IQ != high EQ. Some programmers have the ego that writing code to get the job done and don't border to let other people understand their code, while this kind of attitude is not welcomed by business who is looking for extend-ability and readability. Same as other skilled professionals such as carpenter, they are good in their skill but not good as a team player. They can produce fine work as an individual but they can't build the whole house which require the skill of other professional such as electrician and plumber.

Lets look at a program and see if it is able to fulfill it job and how it can be extended without bring in company politics.

For the above mentioned source, it can handle the new business requirement.
The potential problem here is even with the updated menu.csv file, they are definitely some nasty clients who put the following orders.

Since You Tiao is the same price as Butterfly Bun and Friend Red Bean Bun and they are exchangeable, is it possible to order 2 You Tiao , 2 Butterfly Bun and 1 Friend Red Bean Bun, and pay the same price as 5 You Tiao?

If you are the business owner, what will you say?
If you are the cashier, how will you enter the order to get the discount price?
If you are the technician who asked to maintain the system, what will you do?
If you are the programmer who asked to change the program / system, what will you do?
flashang
post Mar 4 2023, 09:54 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Mar 4 2023, 04:37 PM)
A senior programmer might not be a good programmer and a junior programmer might not be a bad programmer.
As we see in Big Bang Theory, high IQ != high EQ. Some programmers have the ego that writing code to get the job done and don't border to let other people understand their code, while this kind of attitude is not welcomed by business who is looking for extend-ability and readability. Same as other skilled professionals such as carpenter, they are good in their skill but not good as a team player. They can produce fine work as an individual but they can't  build the whole house which require the skill of other professional such as electrician and plumber.

Lets look at a program and see if it is able to fulfill it job and how it can be extended without bring in company politics.

For the above mentioned source, it can handle the new business requirement.
The potential problem here is even with the updated menu.csv file, they are definitely some nasty clients who put the following orders.

Since  You Tiao is the same price as Butterfly Bun and  Friend Red Bean Bun and they are exchangeable, is it possible to order 2 You Tiao , 2 Butterfly Bun and 1 Friend Red Bean Bun, and pay the same price as 5 You Tiao?

If you are the business owner, what will you say?
If you are the cashier, how will you enter the order to get the discount price?
If you are the technician who asked to maintain the system, what will you do?
If you are the programmer who asked to change the program / system, what will you do?
*
There might have cases when the order have been made with discount price,
some product is out of stock.
Could the staff replacement products with same original price to the customer ?

Software could help staff to prevent human error. (e.g. auto convert alacarte to set, auto discount)

But, management should prepare some SOP when the system cannot handle some cases.
(e.g. When can replace same / higher price item to customer)

smile.gif


FlierMate4
post Mar 5 2023, 03:17 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
"Youtiao" may not be familiar to other language speakers, I look up the Internet, "fried dough sticks" maybe more an ideal name. laugh.gif


TSWongGei
post Mar 5 2023, 10:48 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(FlierMate4 @ Mar 5 2023, 03:17 PM)
"Youtiao" may not be familiar to other language speakers, I look up the Internet, "fried dough sticks" maybe more an ideal name.  laugh.gif
*
It's the business owner decision and not mine.

TSWongGei
post Mar 6 2023, 11:06 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Mar 4 2023, 04:37 PM)
A senior programmer might not be a good programmer and a junior programmer might not be a bad programmer.
As we see in Big Bang Theory, high IQ != high EQ. Some programmers have the ego that writing code to get the job done and don't border to let other people understand their code, while this kind of attitude is not welcomed by business who is looking for extend-ability and readability. Same as other skilled professionals such as carpenter, they are good in their skill but not good as a team player. They can produce fine work as an individual but they can't  build the whole house which require the skill of other professional such as electrician and plumber.

Lets look at a program and see if it is able to fulfill it job and how it can be extended without bring in company politics.

For the above mentioned source, it can handle the new business requirement.
The potential problem here is even with the updated menu.csv file, they are definitely some nasty clients who put the following orders.

Since  You Tiao is the same price as Butterfly Bun and  Friend Red Bean Bun and they are exchangeable, is it possible to order 2 You Tiao , 2 Butterfly Bun and 1 Friend Red Bean Bun, and pay the same price as 5 You Tiao?

If you are the business owner, what will you say?
If you are the cashier, how will you enter the order to get the discount price?
If you are the technician who asked to maintain the system, what will you do?
If you are the programmer who asked to change the program / system, what will you do?
*
Lets look at the menu.csv file after 3 new lines being added for 5 * you Tiao / Butterfly Bun / Friend Red Bean Bun = 20% discount

...
E1,5 You Tiao,4,2,2,2,2,2
E2,5 Butterfly Bun,4,1,1,1,1,1
E3,5 Friend Red Bean Bun,4,4,4,4,4,4

This should be the improved version of the menu.csv
Then with the nasty client request , the owner agree that 2 You Tiao , 2 Butterfly Bun and 1 Friend Red Bean Bun also entitle the same discount.
Luckily, the program is designed to handle this without changes, just update the menu.csv to handle that

E4,20 discount 1,4,2,2,1,1,4
E5,20 discount 2,4,2,2,1,1,2
E6,20 discount 3,4,2,2,1,1,1
.....
And the list goes on.

The programmer was brought in and he just inform the technician that this can be done and the technician manully added all the possible combination into the menu.csv.
So, how long you think the technician will take to update 21 lines (all possible combinations of 3 items)

After 15 minutes, the technician happily update the menu.csv and handover to the business owner, and the cashier happily put up the 20% discount.

Isn't this sounds familiar with our daily life as a programmer and technician?

What is the possible bad thing that you can foresee here?

user posted image

This post has been edited by WongGei: Mar 6 2023, 06:06 PM
teckyuan
post Mar 7 2023, 12:02 AM

Getting Started
**
Junior Member
137 posts

Joined: Mar 2008


nosql if you want durable data or redis for transient should be sufficient.
static data load from csv into nosql or redis.
a database is overkill.
TSWongGei
post Mar 7 2023, 10:45 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Mar 6 2023, 11:06 AM)

What is the possible bad thing that you can foresee here?

user posted image
*
1.) Manual update menu.csv file are error prompt.
2.) Might not cover all cases
3.) Not enough testing has been performed.
4.) The combination will grow ex potentially when the bulk number increase and/or the electable items increase.

S1.) Problem 1 and 2 can still be solved by using 2 independent editor and compare their result.
S2.) Problem 2 and 3 can ask ChatGPT to help generate the necessary test case or at least we now there are 21 combinations in advance.
S3.) Problem 4 can ask CharGPT to display all the possible combination , copy and paste the result into menu.csv. Or write a program to generates the possible combination to update the mene.csv accordingly.

From S2 and S3, we can foresee that using AI assisted program will be the future trend.
A lot of minor and repetitive jobs that can be done by more human are totally replaced by AI.
More and more university graduates will find them even harder to look for new jobs cause they have been replaced by AI

Interestingly, I asked ChatGPT to showcase me all the possible combinations and it can't get me a satisfied answer yet.

So, I wrote a program to generates all the possible combination to make 5 draws of the A,B,C characters.

A,A,A,A,A
A,A,A,A,B
A,A,A,A,C
A,A,A,B,B
A,A,A,B,C
A,A,A,C,C
A,A,B,B,B
A,A,B,B,C
A,A,B,C,C
A,A,C,C,C
A,B,B,B,B
A,B,B,B,C
A,B,B,C,C
A,B,C,C,C
A,C,C,C,C
B,B,B,B,B
B,B,B,B,C
B,B,B,C,C
B,B,C,C,C
B,C,C,C,C
C,C,C,C,C


I used about 2 hours to write and debug the program and charGPT use just few seconds to know that there should be 21 lines.
Even though it is unable to provides a satisfied answer, Im sure it will eventually after another few rounds of training. flex.gif

FlierMate4
post Mar 7 2023, 01:34 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(WongGei @ Mar 7 2023, 10:45 AM)
So, I wrote a program to generates all the possible combination to make 5 draws of the A,B,C characters.

A,A,A,A,A
A,A,A,A,B
A,A,A,A,C
A,A,A,B,B
A,A,A,B,C
A,A,A,C,C
A,A,B,B,B
A,A,B,B,C
A,A,B,C,C
A,A,C,C,C
A,B,B,B,B
A,B,B,B,C
A,B,B,C,C
A,B,C,C,C
A,C,C,C,C
B,B,B,B,B
B,B,B,B,C
B,B,B,C,C
B,B,C,C,C
B,C,C,C,C
C,C,C,C,C
I used about 2 hours to write and debug the program and charGPT use just few seconds to know that there should be 21 lines.
*
This is interesting, as I haven't thought of how to generate 3 possible combination in 5 characters.

As a bonus, you can also post the code for this generator. drool.gif
TSWongGei
post Mar 7 2023, 03:31 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(FlierMate4 @ Mar 7 2023, 01:34 PM)
This is interesting, as I haven't thought of how to generate 3 possible combination in 5 characters.

As a bonus, you can also post the code for this generator.  drool.gif
*
Here you go,
https://github.com/wonggei/combination/blob/main/combi.cpp

Not sure why unable to attach my cpp file. Must be some antivirus problem.
FlierMate4
post Mar 7 2023, 04:10 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(WongGei @ Mar 7 2023, 03:31 PM)
Here you go,
https://github.com/wonggei/combination/blob/main/combi.cpp

Not sure why unable to attach my cpp file. Must be some antivirus problem.
*
Thanks, I haven't ran it, from what I see, you use recursion, wow nice.

As a side note, you don't have other code repo hosted on your GitHub, or they are all commercial projects?
Sorry you can choose not to answer as this is your privacy.


TSWongGei
post Mar 7 2023, 05:07 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(FlierMate4 @ Mar 7 2023, 04:10 PM)
Thanks, I haven't ran it, from what I see, you use recursion, wow nice.

As a side note, you don't have other code repo hosted on your GitHub, or they are all commercial projects?
Sorry you can choose not to answer as this is your privacy.
*
Other projects are private.
Lord Tiki Mick
post Mar 7 2023, 05:07 PM

Regular
******
Senior Member
1,020 posts

Joined: Jul 2012
As a senior developer, I'd just code based on the current requirements. 😌
TSWongGei
post Mar 7 2023, 09:25 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(Lord Tiki Mick @ Mar 7 2023, 05:07 PM)
As a senior developer, I'd just code based on the current requirements. 😌
*
That's nothing wrong with that. As a senior developer, I'm sure you know how to make room for further expansion.
silverhawk
post Mar 9 2023, 02:52 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(WongGei @ Mar 7 2023, 10:45 AM)
1.) Manual update menu.csv file are error prompt.
2.) Might not cover all cases
3.) Not enough testing has been performed.
4.)  The combination will grow ex potentially when the bulk number increase and/or the electable items increase.

S1.) Problem 1 and 2 can still be solved by using 2 independent editor and compare their result.
S2.) Problem 2 and 3 can ask ChatGPT to help generate the necessary test case or at least we now there are 21 combinations in advance.
S3.) Problem 4 can ask CharGPT to display all the possible combination , copy and paste the result into menu.csv. Or write a program to generates the possible combination to update the mene.csv accordingly.

From S2 and S3, we can foresee that using AI assisted program will be the future trend.
A lot of minor and repetitive jobs that can be done by more human are totally replaced by AI.
More and more university graduates will find them even harder to look for new jobs cause they have been replaced by AI

Interestingly, I asked ChatGPT to showcase me all the possible combinations and it can't get me a satisfied answer yet.

So, I wrote a program to generates all the possible combination to make 5 draws of the A,B,C characters.

A,A,A,A,A
A,A,A,A,B
A,A,A,A,C
A,A,A,B,B
A,A,A,B,C
A,A,A,C,C
A,A,B,B,B
A,A,B,B,C
A,A,B,C,C
A,A,C,C,C
A,B,B,B,B
A,B,B,B,C
A,B,B,C,C
A,B,C,C,C
A,C,C,C,C
B,B,B,B,B
B,B,B,B,C
B,B,B,C,C
B,B,C,C,C
B,C,C,C,C
C,C,C,C,C
I used about 2 hours to write and debug the program and charGPT use just few seconds to know that there should be 21 lines.
Even though it is unable to provides a satisfied answer, Im sure it will eventually after another few rounds of training.  flex.gif
*
If the same price product is inter-changeable, then which product it is doesn't matter at all. Quite pointless to generate the whole combination.

Using a single CSV also severely limits what you can do, as you're stuck with a single 2D data structure. You could use multiple csv files like products.csv promotion.csv then you start to realise you're building a mini Relational database laugh.gif
junyian
post Mar 9 2023, 08:25 AM

Casual
***
Junior Member
401 posts

Joined: Jan 2003


QUOTE(silverhawk @ Mar 9 2023, 02:52 AM)
If the same price product is inter-changeable, then which product it is doesn't matter at all. Quite pointless to generate the whole combination.

Using a single CSV also severely limits what you can do, as you're stuck with a single 2D data structure. You could use multiple csv files like products.csv promotion.csv then you start to realise you're building a mini Relational database laugh.gif
*
When it reach that point, easier to migrate the csvs to a file-based database like SQLite. No need something overkill like PostgreSQL/MySQL yet.
Then later got requirements to keep track of sales, analysis of best selling promos, etc. etc. (imagination starting to run wild rclxm9.gif ).

And before we know it, we have an open source POS system born from a single post in Lowyat forum brows.gif

flashang
post Mar 9 2023, 10:22 AM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(junyian @ Mar 9 2023, 08:25 AM)
When it reach that point, easier to migrate the csvs to a file-based database like SQLite. No need something overkill like PostgreSQL/MySQL yet.
Then later got requirements to keep track of sales, analysis of best selling promos, etc. etc. (imagination starting to run wild  rclxm9.gif ).

And before we know it, we have an open source POS system born from a single post in Lowyat forum  brows.gif
*
A complete workable system (or people are willing to use)
Should help the real user to solve real life issues.

E.g.
Order will send to kitchen printer.
Cash / E-Wallet / Card receive payment.
Daily reports.

smile.gif


silverhawk
post Mar 9 2023, 10:39 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(junyian @ Mar 9 2023, 08:25 AM)
When it reach that point, easier to migrate the csvs to a file-based database like SQLite. No need something overkill like PostgreSQL/MySQL yet.
Then later got requirements to keep track of sales, analysis of best selling promos, etc. etc. (imagination starting to run wild  rclxm9.gif ).

And before we know it, we have an open source POS system born from a single post in Lowyat forum  brows.gif
*
Should just sqlite from the start, really no reason to be using a CSV file as the data source

Even full blown POS don't need to use Postregre or MySQL. If you want to do cloud syncing and stuff, its actually better to use RqLite which gives you distributed sqlite.
TSWongGei
post Mar 11 2023, 01:15 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
CSV, NoSQL or SQL server, its just a way to store data. The problem I wanted to highlight is how to generates that set of data and how to make sure that set of data is the correct set of data. Without the data, that's nothing to store ....


This post has been edited by WongGei: Mar 11 2023, 01:17 PM
TSWongGei
post Mar 13 2023, 08:06 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Mar 9 2023, 02:52 AM)
If the same price product is inter-changeable, then which product it is doesn't matter at all. Quite pointless to generate the whole combination.
Its a very good point. Lets see how easy to implement this and what limitation will it impose on the original program.

Its really not that hard.

https://github.com/wonggei/priceoptimizatio...main/senior.cpp
flashang
post Mar 16 2023, 10:58 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


Just notice this line...

QUOTE(WongGei @ Mar 4 2023, 04:37 PM)
A senior programmer might not be a good programmer and a junior programmer might not be a bad programmer.
Most people may believe senior professional should be good at their work,
their skills set, and should learn from them.

smile.gif

Should we think "a bad programmer does not deserve to be a senior programmer" ?

doh.gif

Or should we called such people "a senior but bad programmer" ?
Is this an insult of their work (not skill) ?

doh.gif


silverhawk
post Mar 17 2023, 10:15 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(flashang @ Mar 16 2023, 10:58 PM)
Just notice this line...
Most people may believe senior professional should be good at their work,
their skills set, and should learn from them.

smile.gif

Should we think "a bad programmer does not deserve to be a senior programmer" ?

doh.gif 

Or should we called such people "a senior but bad programmer" ?
Is this an insult of their work (not skill) ?

doh.gif
*
The problem is the term junior/senior. Its a word which is based on temporal experience rather than tangible experience. So if someone worked for 10 years and didn't do much, they're still considered "senior" even though got those who worked 2 years but experienced a lot more.

Too bad we don't really have ways to quantify actual skill/experience. So seniority has to stand in as a lousy estimate.
angch
post Mar 17 2023, 11:17 AM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(silverhawk @ Mar 17 2023, 10:15 AM)
The problem is the term junior/senior. Its a word which is based on temporal experience rather than tangible experience. So if someone worked for 10 years and didn't do much, they're still considered "senior" even though got those who worked 2 years but experienced a lot more.

Too bad we don't really have ways to quantify actual skill/experience. So seniority has to stand in as a lousy estimate.
*
Dunno about you guys, but I'm still junior, at least according to LYN's description of my profile (look to the left). Need to up the post counts before I'm not junior. Damn it's hard. Been trying years.

This post has been edited by angch: Mar 17 2023, 11:17 AM
silverhawk
post Mar 17 2023, 02:45 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(angch @ Mar 17 2023, 11:17 AM)
Dunno about you guys, but I'm still junior, at least according to LYN's description of my profile (look to the left). Need to up the post counts before I'm not junior. Damn it's hard. Been trying years.
*
Forever young laugh.gif
ngaisteve2
post Mar 24 2023, 12:39 PM

Getting Started
**
Junior Member
248 posts

Joined: Nov 2021
I think there is one missing level, Mid-Level (between junior and senior).

Actually, the term junior depends also on the company you work for. Someone who is a senior in a small local company can be just a junior in a MNC company. Try to apply for a junior position at Microsoft. I bet it will be crazy challenging for many of us. Haha..
ngaisteve2
post Mar 24 2023, 03:37 PM

Getting Started
**
Junior Member
248 posts

Joined: Nov 2021
user posted image

This will be my initial database design for this Cafe POS system.

Next will be the UI / UX mockup design. But UI / UX is not my strength laugh.gif

After that only I will approach the system owner to finalize the requirements before starting the development (coding).
Tullamarine
post Mar 27 2023, 12:47 AM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(ngaisteve2 @ Mar 24 2023, 03:37 PM)
user posted image

This will be my initial database design for this Cafe POS system.

Next will be the UI / UX mockup design. But UI / UX is not my strength  laugh.gif

After that only I will approach the system owner to finalize the requirements before starting the development (coding).
*
Hi Steve, I am interested to take a look at your CafePOS, but I can't open:
https://github.com/ngaisteve1/CafePos
ngaisteve2
post Mar 27 2023, 05:47 AM

Getting Started
**
Junior Member
248 posts

Joined: Nov 2021
QUOTE(Tullamarine @ Mar 27 2023, 12:47 AM)
Hi Steve, I am interested to take a look at your CafePOS, but I can't open:
https://github.com/ngaisteve1/CafePos
*
Nothing much there except for a bunch of entity class

 

Change to:
| Lo-Fi Version
0.0619sec    0.52    6 queries    GZIP Disabled
Time is now: 24th December 2025 - 11:13 AM