Core Concepts

Description

Mind Map on Core Concepts, created by Bhavit Chhatralia on 22/05/2014.
Bhavit Chhatralia
Mind Map by Bhavit Chhatralia, updated more than 1 year ago
Bhavit Chhatralia
Created by Bhavit Chhatralia almost 10 years ago
54
0

Resource summary

Core Concepts
  1. Code Styles
    1. General Principles
      1. Document any deviations
        1. Adhere Principle of Least Astonishment
          1. adhere to the style of the original
          2. Least astonishment
            1. Simplicity
              1. Build simple classes and simple methods.
              2. Clarity
                1. Ensure each class, interface, method, variable, and object has a clear purpose.
                2. Completeness
                  1. Provide the minimum functionality that any reasonable user would expect to find and use. Create complete documentation
                  2. Consistency
                    1. Similar entities look,behave the same; dissimilar entities look,behave differently. Create and apply standards
                    2. Robustness
                      1. Provide predictable documented behavior in response to errors and exceptions. Do not hide errors and do not force clients to detect errors.
                    3. Formatting Conventions
                      1. Indent nested code
                        1. Specify the amount of space and use of tabs
                        2. Break up long lines
                          1. Split long expressions
                          2. Include white space not just between lines
                          3. Naming conventions
                            1. Use meaningful names (Including constants instead of literals)
                              1. Question excessively long names
                                1. Join the vowel generation (don't shorten by taking vowels out)
                                  1. Use familiar names (for the target domain)
                                    1. Do not use names that differ only in case
                                      1. Capitalize only the first letter in acronyms
                                        1. package Names
                                          1. Use the reversed, lowercase form of your organization's Internet domain name as the root qualifier for your package names
                                            1. Use the same name for a new version of a package, but only if that new version is still binary compatible with the previous version, otherwise, use a new name
                                              1. Use a single, lowercase word as the root name of each package
                                              2. method Names
                                                1. Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a method name
                                                  1. Use verbs when naming methods
                                                    1. Follow the JavaBeans™ conventions for naming property accessor methods
                                                    2. type Names
                                                      1. Same name for a new version of a package, but only if that new version is still binary compatible with the previous version, otherwise, use a new name
                                                        1. Use nouns when naming classes
                                                          1. Use nouns or adjectives when naming interfaces
                                                            1. Pluralize the names of classes that group related attributes, static services, or constants
                                                            2. field Names
                                                              1. Use uppercase letters for each word and separate each pair of words with an underscore when naming constants
                                                                1. When a constructor or "set" method assigns a parameter to afield, give that parameter the same name as the field
                                                                2. variable Names
                                                                  1. Use nouns to name variables
                                                                    1. Pluralize the names of collection references
                                                                      1. Use lowercase for the first word and capitalize only the first letter of each word in variable name
                                                                        1. Establish and use a set of standard names for trivial "throwaway" variables
                                                                      2. Other conventions
                                                                        1. Documentation conventions
                                                                          1. Programming conventions Do not repeat statements or expressions, replace with methods
                                                                            1. Packaging conventions
                                                                          2. Basic Tools
                                                                            1. Integrated Development Environment
                                                                              1. System that combines an editor with language specific support tools, including a debugger
                                                                                1. Standard basic features are:
                                                                                  1. Debugger
                                                                                    1. Code Completion
                                                                                      1. Automatic Indentation
                                                                                        1. Syntax highlighting
                                                                                          1. Complication error highlighting
                                                                                            1. Automate common tasks
                                                                                            2. The master should always work:
                                                                                              1. Updates to working copies
                                                                                                1. Changes quickly updated to repository
                                                                                                  1. Commit triggers build and test
                                                                                                    1. System largely automated
                                                                                                      1. Build results often promiently communicated to developers
                                                                                                    2. Revision Control
                                                                                                      1. Manga sharing of code between team etc.
                                                                                                        1. Integration in IDE allows to see changes made even in the editor
                                                                                                          1. Going back and forth between revisions
                                                                                                          2. Build systems
                                                                                                            1. Generally powerful scripting environments, that do other stuff to.
                                                                                                              1. Automate various tasks related to building software
                                                                                                                1. "Target"s allow a user to specify what needs to be done
                                                                                                                  1. Standard systems:
                                                                                                                    1. Ant - java
                                                                                                                      1. Maven - java project management
                                                                                                                        1. Make - For C/C++ (unix)
                                                                                                                      2. Static analyzers
                                                                                                                        1. Compilers are designed to translate software into executable code
                                                                                                                          1. Most languages don't enforce conventions neither do compilers.
                                                                                                                            1. Conventions can promote correctness
                                                                                                                              1. Complex analysis can find bugs in "valid" code
                                                                                                                                1. May score code on "correctness" dimensions
                                                                                                                                  1. Can check for certain broken patterns
                                                                                                                                  2. Code Formatters
                                                                                                                                    1. Code readability helps understanding,correctness, maintenance
                                                                                                                                      1. Formatters automatically format code
                                                                                                                                        1. Help with conformance to code style + consistency
                                                                                                                                        2. Refactoring
                                                                                                                                          1. When code changes, the design may change along
                                                                                                                                            1. Changing the organisation of code or design of the system is called refactoring
                                                                                                                                              1. Refactoring involves aspects such as:
                                                                                                                                                1. Renaming "things"
                                                                                                                                                  1. Reordering parameters
                                                                                                                                                    1. Introducing Classes or interfaces
                                                                                                                                                      1. Moving Methods
                                                                                                                                                    2. Debugging
                                                                                                                                                      1. Step over - go to next line
                                                                                                                                                        1. Step into - go into the function on this line
                                                                                                                                                          1. Step out - go to calling function
                                                                                                                                                            1. Breakpoint - stop execution here, on exception or value change
                                                                                                                                                              1. Watch - Expressions you want evaluated
                                                                                                                                                                1. Local variables - visible in program + value
                                                                                                                                                              2. Collections
                                                                                                                                                                1. What is a collection
                                                                                                                                                                  1. Object that groups together various objects
                                                                                                                                                                    1. used to hold similar data items - cards, msg in chatbox
                                                                                                                                                                      1. Arrays are a sort of collections
                                                                                                                                                                      2. What is Java Collections Framework
                                                                                                                                                                        1. group of interfaces and classes for dealing with differing types of collections
                                                                                                                                                                          1. Interfaces – abstract data types
                                                                                                                                                                            1. Implementations – ready made classes
                                                                                                                                                                              1. Methods – static methods that work on collections
                                                                                                                                                                              2. encourages code reuse
                                                                                                                                                                                1. facilitates interoperability
                                                                                                                                                                                  1. abstracts complex data structures between easy to understand (common) interfaces
                                                                                                                                                                                  2. Arrays
                                                                                                                                                                                    1. Size is fixed when the array is constructed
                                                                                                                                                                                      1. You must be able to predict array size
                                                                                                                                                                                        1. Items have a fixed index position
                                                                                                                                                                                        2. ArrayListS
                                                                                                                                                                                          1. Stores stuff in an array (and moves it to a new array if capacity is insufficient)
                                                                                                                                                                                            1. Maintains entry order
                                                                                                                                                                                              1. Changing a location is cheap [ O(1) ]
                                                                                                                                                                                                1. Finding an item is expensive [ O(n) ]
                                                                                                                                                                                                  1. Getting an item at a specified random location is cheap [ O(1) ]
                                                                                                                                                                                                    1. Adding stuff at the end is cheap (in most cases, except when copying is needed) [ O(1) ]
                                                                                                                                                                                                      1. Putting things in the middle or removing things from the middle is expensive [ O(n) ]
                                                                                                                                                                                                      2. HashMap (hashing)
                                                                                                                                                                                                        1. Stores key -> value pairs
                                                                                                                                                                                                          1. Key is hashed
                                                                                                                                                                                                            1. Hash is used as index into an array, where the value is stored (often in a linked list)
                                                                                                                                                                                                              1. Finding elements is cheap [ O(1) ]
                                                                                                                                                                                                                1. Removing of elements is cheap [ O(1) ]
                                                                                                                                                                                                                  1. Memory need is bigger
                                                                                                                                                                                                                    1. Hash key calculation can be expensive
                                                                                                                                                                                                                      1. Collection does not maintain order
                                                                                                                                                                                                                        1. No random access
                                                                                                                                                                                                                          1. Iterating a bit more expensive than arraylists
                                                                                                                                                                                                                            1. HashSet
                                                                                                                                                                                                                              1. same as HashMap only value is stored in key as well
                                                                                                                                                                                                                                1. enforces uniqueness
                                                                                                                                                                                                                              2. TreeMap/Set
                                                                                                                                                                                                                                1. Stores in a tree
                                                                                                                                                                                                                                  1. Maintains items in key order
                                                                                                                                                                                                                                    1. Adding, removing and finding items has moderate complexity [ O(log n) ]
                                                                                                                                                                                                                                      1. Reasonable memory usage
                                                                                                                                                                                                                                        1. No random indexed access
                                                                                                                                                                                                                                          1. Iterating a bit more expensive than arraylists
                                                                                                                                                                                                                                          2. Linked List
                                                                                                                                                                                                                                            1. Every element has a link to the next + or prev ele
                                                                                                                                                                                                                                              1. Adding an element is cheap [ O(1) ]
                                                                                                                                                                                                                                                1. Finding an element is expensive [ O(n) ] needs to look from beginning (on average 1/2 n steps)
                                                                                                                                                                                                                                                  1. Removing an element anywhere is cheap [ O(2) ]
                                                                                                                                                                                                                                                    1. Maintains entry order
                                                                                                                                                                                                                                                      1. LinkedHashMap/Set
                                                                                                                                                                                                                                                        1. Combine hashmap/set with linked lists
                                                                                                                                                                                                                                                          1. maintain entry order of adding items to from list
                                                                                                                                                                                                                                                            1. Computational properties of HashMaps
                                                                                                                                                                                                                                                          2. Deque - Double ended queue
                                                                                                                                                                                                                                                            1. New in jdk 1.6 / Java 6
                                                                                                                                                                                                                                                              1. Like array list, but instead of a window starting at index 0 of the array, maintains a sliding window over the array.
                                                                                                                                                                                                                                                                1. Cheap adding/removing entries at beginning of list
                                                                                                                                                                                                                                                                  1. A little more expensive because of the index
                                                                                                                                                                                                                                                                    1. In general a very efficient data type
                                                                                                                                                                                                                                                                  2. Object Orientation
                                                                                                                                                                                                                                                                    1. References and pointers
                                                                                                                                                                                                                                                                      1. pointer is a data type that contains the address of some data in memory
                                                                                                                                                                                                                                                                        1. To use the pointed to values, the language must provide indirection operators
                                                                                                                                                                                                                                                                          1. A pointer must point to a valid location. Either allocated (new) or pre-existing
                                                                                                                                                                                                                                                                            1. A reference is a language feature that makes abstracts pointer indirection and hides the pointer
                                                                                                                                                                                                                                                                              1. In Java all Objects are used through references. Pointers are not available
                                                                                                                                                                                                                                                                              2. What is OO?
                                                                                                                                                                                                                                                                                1. A programming paradigm (approach to...)
                                                                                                                                                                                                                                                                                  1. combination of a number of programming concepts into 1
                                                                                                                                                                                                                                                                                    1. solution particularly well suited to certain problems
                                                                                                                                                                                                                                                                                      1. Not a silver bullet / panacea
                                                                                                                                                                                                                                                                                        1. What makes up OO?
                                                                                                                                                                                                                                                                                          1. Data structure
                                                                                                                                                                                                                                                                                            1. Create a new kind of "data" that is built out of constituent components
                                                                                                                                                                                                                                                                                              1. Members can be contained, or be references to structures
                                                                                                                                                                                                                                                                                                1. Membership can logically be
                                                                                                                                                                                                                                                                                                  1. Containment - indistinguishable part, same lifetime
                                                                                                                                                                                                                                                                                                    1. Ownership - the outer object is responsible for the lifetime of the object, and handling access to it
                                                                                                                                                                                                                                                                                                      1. Reference - the outer object keeps a link to the object but has no responsibility in its lifetime
                                                                                                                                                                                                                                                                                                    2. Modularisation
                                                                                                                                                                                                                                                                                                      1. Code visibility
                                                                                                                                                                                                                                                                                                        1. Code reuse
                                                                                                                                                                                                                                                                                                          1. Abstraction (Abstract datatypes)
                                                                                                                                                                                                                                                                                                        2. What is a Struct
                                                                                                                                                                                                                                                                                                          1. Defines a "sequential" layout of values
                                                                                                                                                                                                                                                                                                            1. Allows treating as parts
                                                                                                                                                                                                                                                                                                              1. Element name is offset into memory
                                                                                                                                                                                                                                                                                                                1. Data / machine oriented
                                                                                                                                                                                                                                                                                                                  1. Members are contained in the "in-memory" layout of the type
                                                                                                                                                                                                                                                                                                                    1. Containment implies ownership
                                                                                                                                                                                                                                                                                                                      1. By default members are public
                                                                                                                                                                                                                                                                                                                        1. Structs vs Classes
                                                                                                                                                                                                                                                                                                                          1. Java Objects are always used by reference (no containment).
                                                                                                                                                                                                                                                                                                                            1. Use of other objects can have the intent of reference, ownership or containment
                                                                                                                                                                                                                                                                                                                          2. Modularisation
                                                                                                                                                                                                                                                                                                                            1. Modularisation is breaking up code into parts
                                                                                                                                                                                                                                                                                                                              1. Plain use of methods/functions is not modularisation
                                                                                                                                                                                                                                                                                                                                1. module should have some sort of coherency
                                                                                                                                                                                                                                                                                                                                  1. Makes it easier to find and edit parts of the system.
                                                                                                                                                                                                                                                                                                                                  2. Code Reuse
                                                                                                                                                                                                                                                                                                                                    1. Good prog reuses code
                                                                                                                                                                                                                                                                                                                                      1. less code = less complex
                                                                                                                                                                                                                                                                                                                                        1. reuse = code faster
                                                                                                                                                                                                                                                                                                                                          1. reuse = effort into better code
                                                                                                                                                                                                                                                                                                                                            1. reuse = changes in 1 place
                                                                                                                                                                                                                                                                                                                                              1. Ways
                                                                                                                                                                                                                                                                                                                                                1. Inheritance - allows a class to use the implementation in it's ancestor.
                                                                                                                                                                                                                                                                                                                                                  1. Generics, allow limited variation on type constraints only (mainly help correctness)
                                                                                                                                                                                                                                                                                                                                                    1. Temp, allow variations preventing copy,paste
                                                                                                                                                                                                                                                                                                                                                      1. ctrl c,v,+ edit = same (bad)
                                                                                                                                                                                                                                                                                                                                                        1. Function implementing an algorithm (Collections.sort)
                                                                                                                                                                                                                                                                                                                                                      2. Abstract Data Types
                                                                                                                                                                                                                                                                                                                                                        1. Abstract - "theoretical rather than physical or concrete"
                                                                                                                                                                                                                                                                                                                                                          1. in prog - the what from the how
                                                                                                                                                                                                                                                                                                                                                            1. Comp Science concept
                                                                                                                                                                                                                                                                                                                                                              1. Specifying a data (and its corresponding functions) type purely by its external properties
                                                                                                                                                                                                                                                                                                                                                                1. Allows to reason about something that holds (is true) for all possible implementations
                                                                                                                                                                                                                                                                                                                                                                  1. Use in implementation ensures implementation independence
                                                                                                                                                                                                                                                                                                                                                                    1. Uses
                                                                                                                                                                                                                                                                                                                                                                      1. If your algorithm works on an ADT it works on all types implementing it (code reuse)
                                                                                                                                                                                                                                                                                                                                                                        1. Allows for multiple implementations with different strengths (change has local impact on code)
                                                                                                                                                                                                                                                                                                                                                                          1. Allow context-dependent use of specific implementation (don't return an empty ArrayList, but Collections.emptyList)
                                                                                                                                                                                                                                                                                                                                                                            1. Separate function from implementation
                                                                                                                                                                                                                                                                                                                                                                          2. Interface
                                                                                                                                                                                                                                                                                                                                                                            1. Users should always read documentation for the "hidden" contract
                                                                                                                                                                                                                                                                                                                                                                              1. Only specifies an abstract data type
                                                                                                                                                                                                                                                                                                                                                                                1. Specifies a particular contract that classes can implement, and users can expect.
                                                                                                                                                                                                                                                                                                                                                                                  1. Non-visible parts should be documented
                                                                                                                                                                                                                                                                                                                                                                                    1. Parts of the contract are not visible in code
                                                                                                                                                                                                                                                                                                                                                                                    2. Inheritance
                                                                                                                                                                                                                                                                                                                                                                                      1. Java = public relationship
                                                                                                                                                                                                                                                                                                                                                                                        1. class = interface
                                                                                                                                                                                                                                                                                                                                                                                          1. In memory, an instance is like a structure where the first member is a contained, anonymous version of the parent
                                                                                                                                                                                                                                                                                                                                                                                            1. Private members allow hiding implementation from children.
                                                                                                                                                                                                                                                                                                                                                                                              1. Protected allows access by children, but not by users.
                                                                                                                                                                                                                                                                                                                                                                                                1. Final protects agains inheritance. Final classes can't be inherited. Final members can't be overridden
                                                                                                                                                                                                                                                                                                                                                                                                2. Abstract classes (and methods)
                                                                                                                                                                                                                                                                                                                                                                                                  1. Fully abstract class is an interface (e.g. C++ has no interface concept)
                                                                                                                                                                                                                                                                                                                                                                                                    1. Some implementations are provided either for convenience, or to enforce behaviour.
                                                                                                                                                                                                                                                                                                                                                                                                      1. Abstract methods provide a contract, but no implementation
                                                                                                                                                                                                                                                                                                                                                                                                        1. Abstract classes miss implementation for some methods, and are thus designed for extension
                                                                                                                                                                                                                                                                                                                                                                                                        2. Polymorphism
                                                                                                                                                                                                                                                                                                                                                                                                          1. Technique to run different code based on type of an object at run time
                                                                                                                                                                                                                                                                                                                                                                                                            1. Each object maintains a reference to it's actual type (set at creation time).
                                                                                                                                                                                                                                                                                                                                                                                                              1. When calling a method, instead of going to the address of that method, look the method address up in the class (in C++ vtable).
                                                                                                                                                                                                                                                                                                                                                                                                                1. Different classes can point to different implementations for the same method name
                                                                                                                                                                                                                                                                                                                                                                                                                  1. Depends on exact method signature match.
                                                                                                                                                                                                                                                                                                                                                                                                                    1. Depends on exact method signature match.
                                                                                                                                                                                                                                                                                                                                                                                                                      1. @Override annotation conveys intention to compiler that verifies the intention
                                                                                                                                                                                                                                                                                                                                                                                                                    Show full summary Hide full summary

                                                                                                                                                                                                                                                                                                                                                                                                                    Similar

                                                                                                                                                                                                                                                                                                                                                                                                                    Society And Culture
                                                                                                                                                                                                                                                                                                                                                                                                                    Sophia Ergos
                                                                                                                                                                                                                                                                                                                                                                                                                    Tectonic Hazards flashcards
                                                                                                                                                                                                                                                                                                                                                                                                                    katiehumphrey
                                                                                                                                                                                                                                                                                                                                                                                                                    Prática para o TOEFL
                                                                                                                                                                                                                                                                                                                                                                                                                    miminoma
                                                                                                                                                                                                                                                                                                                                                                                                                    B3, C3, P3
                                                                                                                                                                                                                                                                                                                                                                                                                    George Moores
                                                                                                                                                                                                                                                                                                                                                                                                                    Function and Structure of DNA
                                                                                                                                                                                                                                                                                                                                                                                                                    Elena Cade
                                                                                                                                                                                                                                                                                                                                                                                                                    The Rise of the Nazis
                                                                                                                                                                                                                                                                                                                                                                                                                    shann.w
                                                                                                                                                                                                                                                                                                                                                                                                                    Carbohydrates
                                                                                                                                                                                                                                                                                                                                                                                                                    Julia Romanów
                                                                                                                                                                                                                                                                                                                                                                                                                    GRE Verbal Reasoning Vocabulary Flashcards 1
                                                                                                                                                                                                                                                                                                                                                                                                                    Sarah Egan
                                                                                                                                                                                                                                                                                                                                                                                                                    Psychopathology
                                                                                                                                                                                                                                                                                                                                                                                                                    Laura Louise
                                                                                                                                                                                                                                                                                                                                                                                                                    2PR101 1. test - 5. část
                                                                                                                                                                                                                                                                                                                                                                                                                    Nikola Truong
                                                                                                                                                                                                                                                                                                                                                                                                                    3MA114 Management_test 1/2
                                                                                                                                                                                                                                                                                                                                                                                                                    Jakub Beyr