Reading-notes

https://rand92.github.io/Reading-notes/

View project on GitHub

Understanding The Problem Domain Is The Hardest Part Of Programming

What is the hardest thing about writing code?

There are many common answers to this question:

  • Learning a new technology
  • Naming things
  • Testing your code
  • Debugging
  • Fixing bugs
  • Making software maintainable 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:

Make the problem domain easier 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 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.

Games are really good at this. Look at most games today and you’ll find that you start with a very small problem domain. The first level is usually a tutorial that has a basic set of things you can do so that you don’t get overwhelmed. But, as you advance through the levels, you usually find they get harder and introduce new concepts that build gradually on what you know, until you understand a pretty large problem domain

Object literals

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. IN AN OBJECT: VARIABLES BECOME KNOWN AS PROPERTIES If a variable is part of an object, it is called a property. Properties te ll us about the object, such as the name of a hotel or the number of rooms it has. Each individual hotel might have a different name and a different number of rooms. IN AN OBJECT: FUNCTIONS BECOME KNOWN AS METHODS If a function is part of an object, it is called a method. Methods represent tasks that are associated with the object. For example, you can check how many rooms are available by subtracting the number of booked rooms from the total number of rooms

CREATING· OBJECTS USING LITERAL NOTATION

creating an object

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.

WORKING WITHTHE 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.

    NODELISTS: DOM QUERIES THAT RETURN MORE THAN ONE ELEMENT

TRAVERSING THE DOM

When you have an element node, you can select another element in relation to it using these five properties. This is known as traversing the DOM.

REMOVING ELEMENTS VIA DOM MANIPULATION

  • STORE THE ELEMENT TO BE REMOVED IN A VARIABLE
  • STORE THE PARENT OF THAT ELEMENT IN A VARIABLE
  • REMOVE THE ELEMENT FROM ITS CONTA INING ELEMENT

    XSS: ESCAPING &

    CONTROLLING MARKUP Any content generated by users that contain characters that are used in code should be escaped on the server. You must control any markup added to the page.