Skip to content

Typical Java exercise that shows how to build simple OO project and practice skills such as: how to choose appropriate data type for project, how to write clean and consistent code and etc.

License

Notifications You must be signed in to change notification settings

MikhailMS/java-shop-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codacy Badge Build Status

Java shop example

Typical Java exercise that shows how to build simple OO project and practice skills such as: how to choose appropriate data type for project, how to write clean and consistent code and etc.

This project will be written using Java 8 approach, rather than Java 7 and older. As Java 9 is released, maybe some of new Java features will be introduced if needed.

Also I am using TDD approach to complete this project as I found this really convenient way to develop projects in Java. And as extra I'm trying to use Travis CI for building and testing project together with Codacy for keeping my code clean and consistent.

Plan of action:

  • Erase dummy tests for Product, Basket, Order, Inventory, Shop classes and re-write them accordingly

    • ProductTest class
    • BasketTest class
    • OrderTest class
    • InventoryTest class
    • ShopTest class
  • Complete classes mentioned above to see, how application works

    • Product class
    • Basket class
    • Order class
    • Inventory class
    • Shop class
  • In simple version of such exercise, to save data it is proposed to write data into files, however I'll write it into PostgreSQL DB

    • Can save basket into DB
    • Can save order into DB
    • Can restore basket from DB
    • Can restore order from DB
  • As an optional part, I'd like to introduce user system: administration and clients. First would be able to see all completed orders and inventory stock and its total cost, while customers can fill in baskets, make orders and see theirs basket and orders only

    • Administrator user can
      • See all available products
      • See total cost of all products
      • Add products to inventory
      • Remove products from inventory
      • See orders completed by any user
      • See total cost of all completed orders
      • Add user to the system
      • Delete user from system
      • Filter products by name, price and weight
      • Filter orders by date
      • Filter orders by total price
    • Client user can
      • See all available products
      • Add to basket
      • Remove from basket
      • Save basket
      • Restore basket
      • Save order
      • Restore order
      • Complete order
      • See all orders (client can see only his orders)
      • Filter products by name, price and weight
      • Filter orders by date
      • Filter orders by total price
  • As an optional part, I'd like to introduce GUI, which will make it easier to fill basket, see orders and etc

    • Login screen

    • Can login into system and gain appropriate rights

    • Client GUI

      • See all available products
      • Add to basket
      • Remove from basket
      • Complete order
      • See all completed orders (client can see only his orders)
      • See total cost of all completed orders
      • Sort orders by total price
      • Filter orders by total price
      • Search for specific product by name
      • Sort products by name, price and weight
      • Filter products by name, price and weight
    • Administrator GUI

      • See all available products
      • See total cost of all products
      • Add new product to inventory
      • Add products to inventory
      • Remove products from inventory
      • See orders completed by any user
      • See total cost of all completed orders
      • Sort orders by date, total price
      • Filter orders by date/total price
      • Add user to the system
      • Delete user from system
      • Search for specific product by name
      • Sort products by name, price
      • Filter products by price, weight
    • Bring all GUI components into one Stage

      • Create main stage with TabPane(tab panel, that contains scenes)
        • Main stage, which creates tab panels depending on the privilege level of the logged user
        • Save basket
        • Restore basket
      • Connect GUI to database
        • Login GUI
        • Client GUI
          • Highlighted parts
        • Administrator GUI
          • Highlighted parts
    • Finish up tests

      • Review tests for the project so far
      • MainStage GUI tests
        • Client GUI tests
        • Administrator GUI tests
  • As an optional part, I'd like to write a service, which will keep shop's inventory in sync with DB and completed orders

    • Once order is completed, service will update inventory in the DB and update local copy of the inventory
    • It will also check, if order can be made, ie not enough products in the inventory
    • If product(-s) not available to order, notify user and administrator

Bug trace

  • When adding new product via form, product is added, but then I cannot change its amount
  • METHOD DEPRECATED - WILL BE DELETED restoreBasketFromDB method shall be fixed, as currently it's hardcoded to use fixed weight and price for all restored products in Basket
  • When completing order as Client in GUI, basket is not reset. Should find a way to clear it
  • When basket has been restored, restored products cannot be removed.

Improvements, that could be done later

  • At the moment user can add more products into basket than there exist in inventory -> make them talk to one another
  • At the moment there is no column to sort orders by date, but could be added. Will require extra column in GUI and extra filed in Order class
  • At the moment data in rows does not update straight after product has been added/removed to/from basket/inventory, but rather after row been clicked, table been sorted or Details button been clicked
  • At the moment, when new product added to basket/inventory, in order to display it, I delete all entries from observable list + its underlying list

Build and tested on MacOS and Java 1.8 (required)

About

Typical Java exercise that shows how to build simple OO project and practice skills such as: how to choose appropriate data type for project, how to write clean and consistent code and etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages