¡GoConqr estrena diseño! Cuéntanos qué te parece.

Apuntes

Core Concepts - created from Mind Map

Bhavit Chhatralia Programming Inglés 1 página

Contenido del apunte (1)

Página 1

Programming Language Concepts

Code Styles

General Principles

Least astonishment

Formatting Conventions

Naming conventions

Other conventions

Document any deviations

Adhere Principle of Least Astonishment

adhere to the style of the original

Simplicity

Clarity

Completeness

Consistency

Robustness

Build simple classes and simple methods.

Ensure each class, interface, method, variable, and object has a clear purpose.

Provide the minimum functionality that any reasonable user would expect to find and use. Create complete documentation

Similar entities look,behave the same; dissimilar entities look,behave differently. Create and apply standards

Provide predictable documented behavior in response to errors and exceptions. Do not hide errors and do not force clients to detect errors.

Indent nested code

Break up long lines

Include white space not just between lines

Specify the amount of space and use of tabs

Split long expressions

Use meaningful names (Including constants instead of literals)

Question excessively long names

Join the vowel generation (don't shorten by taking vowels out)

Use familiar names (for the target domain)

Do not use names that differ only in case

Capitalize only the first letter in acronyms

package Names

method Names

type Names

field Names

variable Names

Use the reversed, lowercase form of your organization's Internet domain name as the root qualifier for your package names

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

Use a single, lowercase word as the root name of each package

Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a method name

Use verbs when naming methods

Follow the JavaBeans™ conventions for naming property accessor methods

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

Use nouns when naming classes

Use nouns or adjectives when naming interfaces

Pluralize the names of classes that group related attributes, static services, or constants

Use uppercase letters for each word and separate each pair of words with an underscore when naming constants

When a constructor or "set" method assigns a parameter to afield, give that parameter the same name as the field

Use nouns to name variables

Pluralize the names of collection references

Use lowercase for the first word and capitalize only the first letter of each word in variable name

Establish and use a set of standard names for trivial "throwaway" variables

Documentation conventions

Programming conventions Do not repeat statements or expressions, replace with methods

Packaging conventions

Basic Tools

Integrated Development Environment

Revision Control

Build systems

Static analyzers

Code Formatters

Refactoring

Debugging

System that combines an editor with language specific support tools, including a debugger

Standard basic features are:

The master should always work:

Debugger

Code Completion

Automatic Indentation

Syntax highlighting

Complication error highlighting

Automate common tasks

Updates to working copies

Changes quickly updated to repository

Commit triggers build and test

System largely automated

Build results often promiently communicated to developers

Manga sharing of code between team etc.

Integration in IDE allows to see changes made even in the editor

Going back and forth between revisions

Generally powerful scripting environments, that do other stuff to.

Automate various tasks related to building software

"Target"s allow a user to specify what needs to be done

Standard systems:

Ant - java

Maven - java project management

Make - For C/C++ (unix)

Compilers are designed to translate software into executable code

Most languages don't enforce conventions neither do compilers.

Conventions can promote correctness

Complex analysis can find bugs in "valid" code

May score code on "correctness" dimensions

Can check for certain broken patterns

Code readability helps understanding,correctness, maintenance

Formatters automatically format code

Help with conformance to code style + consistency

When code changes, the design may change along

Changing the organisation of code or design of the system is called refactoring

Refactoring involves aspects such as:

Renaming "things"

Reordering parameters

Introducing Classes or interfaces

Moving Methods

Step over - go to next line

Step into - go into the function on this line

Step out - go to calling function

Breakpoint - stop execution here, on exception or value change

Watch - Expressions you want evaluated

Local variables - visible in program + value

Collections

What is a collection

What is Java Collections Framework

Arrays

ArrayListS

HashMap (hashing)

TreeMap/Set

Linked List

Deque - Double ended queue

Object that groups together various objects

used to hold similar data items - cards, msg in chatbox

Arrays are a sort of collections

group of interfaces and classes for dealing with differing types of collections

encourages code reuse

facilitates interoperability

abstracts complex data structures between easy to understand (common) interfaces

Interfaces – abstract data types

Implementations – ready made classes

Methods – static methods that work on collections

Size is fixed when the array is constructed

You must be able to predict array size

Items have a fixed index position

Stores stuff in an array (and moves it to a new array if capacity is insufficient)

Maintains entry order

Changing a location is cheap [ O(1) ]

Finding an item is expensive [ O(n) ]

Getting an item at a specified random location is cheap [ O(1) ]

Adding stuff at the end is cheap (in most cases, except when copying is needed) [ O(1) ]

Putting things in the middle or removing things from the middle is expensive [ O(n) ]

Stores key -> value pairs

Key is hashed

Hash is used as index into an array, where the value is stored (often in a linked list)

Finding elements is cheap [ O(1) ]

Removing of elements is cheap [ O(1) ]

Memory need is bigger

Hash key calculation can be expensive

Collection does not maintain order

No random access

Iterating a bit more expensive than arraylists

HashSet

same as HashMap only value is stored in key as well

enforces uniqueness

Stores in a tree

Maintains items in key order

Adding, removing and finding items has moderate complexity [ O(log n) ]

Reasonable memory usage

No random indexed access

Iterating a bit more expensive than arraylists

Every element has a link to the next + or prev ele

Adding an element is cheap [ O(1) ]

Finding an element is expensive [ O(n) ] needs to look from beginning (on average 1/2 n steps)

Removing an element anywhere is cheap [ O(2) ]

Maintains entry order

LinkedHashMap/Set

Combine hashmap/set with linked lists

maintain entry order of adding items to from list

Computational properties of HashMaps

New in jdk 1.6 / Java 6

Like array list, but instead of a window starting at index 0 of the array, maintains a sliding window over the array.

Cheap adding/removing entries at beginning of list

A little more expensive because of the index

In general a very efficient data type

Object Orientation

References and pointers

What is OO?

What is a Struct

pointer is a data type that contains the address of some data in memory

To use the pointed to values, the language must provide indirection operators

A pointer must point to a valid location. Either allocated (new) or pre-existing

A reference is a language feature that makes abstracts pointer indirection and hides the pointer

In Java all Objects are used through references. Pointers are not available

A programming paradigm (approach to...)

combination of a number of programming concepts into 1

solution particularly well suited to certain problems

Not a silver bullet / panacea

What makes up OO?

Data structure

Modularisation

Code visibility

Code reuse

Abstraction (Abstract datatypes)

Create a new kind of "data" that is built out of constituent components

Members can be contained, or be references to structures

Membership can logically be

Containment - indistinguishable part, same lifetime

Ownership - the outer object is responsible for the lifetime of the object, and handling access to it

Reference - the outer object keeps a link to the object but has no responsibility in its lifetime

Defines a "sequential" layout of values

Allows treating as parts

Element name is offset into memory

Data / machine oriented

Members are contained in the "in-memory" layout of the type

Containment implies ownership

By default members are public

Structs vs Classes

Java Objects are always used by reference (no containment).

Use of other objects can have the intent of reference, ownership or containment

Recursion

Core Concepts

Información

Descripción
Programming Apunte sobre Core Concepts - created from Mind Map, creado por Bhavit Chhatralia el 24/05/2014.
Visitas
41
Historial
  • Creado por Bhavit Chhatralia · 24 may 2014
  • Copiado a Apunte por Bhavit Chhatralia · 24 may 2014
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?