Reading--Notes

Problem Domain

What is the hardest thing about writing code?

here some answers :

  1. Learning a new technology.
  2. Naming things.
  3. Testing your code.
  4. Debugging.
  5. Fixing bugs.
  6. Making software maintainable.

making the problem domain so trivial make it easily understood,like I am able to make both teaching and learning easier.

Why problem domains are hard ?

because you can’t really see what you are trying to build very clearly.

What can you do about it?

If understanding the problem domain is the hardest part of programming and you want to make programming easier, you can do one of two things:

  1. Make the problem domain easier
  2. Get better at understanding the problem domain.

Programming is easy if you understand the problem domain. You can often make the problem domain easier by cutting out cases and narrowing your focus to a particular part of the problem.

What I mean by this is that it is often beneficial to take a part of the problem and fully understand that part before expanding the problem domain.

Javascript

Whats The Object ?

Objects group together a set of variables and functions to create a model of a something you would recognize from the real world. In an object, variables and functions take on new names.

obj

See the example below

obj

Aceess to an object :

obj

Document Object Model

The Document Object Model (DOM) specifies how browsers should create a model of an HTML page and how JavaScript can access and update the contents of a web page while it is in the browser window.

The DOM is neither part of HTML, nor part of JavaScript; it is a separate set of rules. It is implemented by all major browser makers, and covers two primary areas:

  1. Making a model og the html page.
  2. Accessing and changong the html page.
  1. The document node.
  2. Elements node.
  3. Attribute node.
  4. Text node.

tree

WORKING WITH THE DOM TREE:

Accessing and updating the DOM tree involves two steps:

  1. Locate the node that represents the element you want to work with.
  2. Use its text content, child elements, and attributes.

Selcting elements using id attributes :

get El ementByi d () allows you to select a single element node by specifying the value of its id attribute.

id

When a DOM method can return more than one element, it returns a Nodelist (even if it only finds one matching element).

Selcting elements by tag name :

The get El ementsByTagName () method allows you to select elements using their tag name.

Howm to get/update element content :

Adding or removing html content :

there are two different ways to fdo that :

  1. The innerHtml properity.

  2. DOM manipulation.