Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

santosrai/My_JAVA_NoteBook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

My_JAVA_NoteBook

Programming language terms(derived from stackflow)

function

- purpose: process data, manipulate data, create result sets.
- when to use: always code a function if you want to do this: "y=f(x)"

struct/dict/json/etc (instead of class)

- purpose: store attr./param., maintain attr./param., reuse attr./param., use attr./param. later.
- when to use: if you deal with a set of attributes/params (preferably not mutable)
different languages same thing: struct (C/C++), JSON (js), dict (python), etc.
always prefer simple struct/dict/json/etc over complicated classes (keep it simple!)

class (if it is a new data type)

- a simple perspective: is a struct (C), dict (python), json (js), etc. with methods attached.
The method should only make sense in combination with the data/param stored in the class.
- advice: never code complex stuff inside class methods (call an external function instead)
- warning: do not misuse classes as fake namespace for functions! (this happens very often!)
other use cases: if you want to do a lot of operator overloading then use classes (e.g. your own matrix/vector multiplication class)
- ask yourself: is it really a new "data type"? (Yes => class | No => can you avoid using a class)

array/vector/list (to store a lot of data)

- purpose: store a lot of homogeneous data of the same data type, e.g. time series
- advice#1: just use what your programming language already have. do not reinvent it
- advice#2: if you really want your "class mysupercooldatacontainer", then overload an existing array/vector/list/etc class (e.g. "class mycontainer : public std::vector...")

enum (enum class)

- Enum are lists of constants.
- Purpose: When you need a predefined list of values.
- advice#1: use enum plus switch-case instead of overcomplicated OOP design patterns
- advice#2: use finite state machines

About

Java Learning Repo

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /