Understanding the problem domain

The web site hold my reading notes in code 201.

Understanding the problem domain


Understanding The Problem Domain Is The Hardest Part Of Programming

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

You can often make the problem domain easier by cutting out cases and narrowing your focus to a particular part of the problem. ____

WHAT IS AN 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. *

property: if a variable is part of an object.tell us about the object, such as the name of a hotel or the number of rooms it has.

method: if a function is part of an object,represent tasks that are associated with the object.

key: properties and methods.

An object cannot have two keys with the same name. This is because keys are used to access their corresponding values.

literal

access an object

Dot notation vs bracket notation _________

Document Object Model


When the browser loads a web page, it creates a model of the page in memory. The DOM specifies the way in which the browser should structure this model using a DOM tree. The DOM is called an object model because the model (the DOM tree) is made of objects.

domtree

However, some older browsers have not implemented NodeList.forEach() nor Array.from(). This can be circumvented by using Array.prototype.forEach()

var hotlt ems = document .querySelectorAl l (‘ l i . hot’) ; II Store Nodel ist i n array if (hot ltems.length > O) { II If it contains i t ems for (var i=O; i<hotl tems.length; i++) { II Loop throug h each it em hotltems[i] .className = ‘cool’; II Change val ue of class at tri bute }}

With the HTML DOM, you can navigate the node tree using node relationships

Accessing the innerHTML property is the same as accessing the nodeValue of the first child: myTitle = document.getElementById(“demo”).firstChild.nodeValue; another way : myTitle = document.getElementById(“demo”).childNodes[0].nodeValue;

Back to homw page