Showing posts with label answers. Show all posts
Showing posts with label answers. Show all posts

Thursday, 8 January 2015

F452 Writing maintainable programs.

1. Define the following terms:

  • Variable [1]
  • Constant [1]
  • Reserved word [1]
A variable is a named area of memory of a specific data type that can be changed during the running of the program.
A constant is a named area of memory of a specific data type that doesn't change during the running of the program.
A reserved word is an example of a bad identifier name, they are pre existing words in a programming language.

2. Discuss the need for good programing techniques to facilitate the on going maintenance of programs.  [8]

  • Easily understandable identifier names and comments.
  • Appropriately positioned scopes for constants and variables.
  • Consistent/ meaningful identifiers.
  • Well laid out, eg comments, separated blocks.
  • To help others understand your code.
  • To help others build on your code.
  • Functional decomposition (self containing parts of the code by 'encapsulating' them).

Monday, 1 December 2014

The Webernet.



  • The internet is a wire. (could be fibreoptic)
  • 2 computers connected directly using this wire are connected
  • Every computer has its ow unique addresses : IP addresses.
  • We associate domain names with IP addresses. "we're only human."-Human Humanson.
  • Files stored on a server on some computer somewhere.
  • Domain Name Service (DNS) : allows you to find domain names and their IP addresses.
  • Computer indirectly connected to the internet are known as clients.
  • To look at the internet: Client goes through DSL to ISP
  • Computers break sent pictures into smaller chunks, called 'packets'.
  • Routers help direct packets to where they need to go.
  • Every time a packet goes through a router it gets IP code added to the address so that it can be returned through the same servers.
  • The packet size is generally 1kB each (1000 or 1024 bytes)

Monday, 24 November 2014

F452 - String manipulation (c#)


MODULUS:
MOD or % 
the remainder when dividing one number by another
e.g 7 MOD 3 = 1

DIV 
the whole number result
e.g 47 DIV 10 = 4


\r end of line.

\n new line.


Concatenation:
string.Concat(string, "part being added");

Replace:
string.Replace(string, "New string.\n");

Format:
string,Format("{0}: {1:0,0} - {2:yyyy}");

Turning stuff into strings:
datatype.ToString();

Turning strings into integers:
//CAUTION; HANDLE WITH CARE 
(characters cannot be converted)//
int.Parse(text);


A = 1, B = 1 }

AND
&&
e.g IF ((A==2)&&(B==3))
Returns FALSE or 0

OR
||
e.g IF ((A==2)||(B==3))
Returns False or 0

NOT
!
e.g IF (!(A==2))
Returns True or 1


Concatenation
Means joining one or more strings together.

Replace
Lets you replace a given char in a string with another character.

Extract
Returns part of the strings from between two specified elements.

Length
Returns the number of characters in a string.

charCodeAt
Returns the ASCII value of a given element.

SWAP
Swaps two given chars.

HANDY FACTOID:
In ASCII the char A is given the code 65.

Validation:


Presence check:
Is the data present, has the required field been completed?

Length check:
Is the data a suitable length?

Format check:
Correct format? e.g dd/mm/yyyy

Range check:
Is the data in the correct range.

Existence check:
Does the data match something that already exists in the system?




Monday, 10 November 2014

F452 - Development.

Writing bad code is easy; writing good code is difficult; writing really good code is REALLY difficult.


What’s a bug?



A bug is where the software (or system) does something unexpected or undesirable.
Not all bugs are accidents though.


Types of bugs:



  • Functional: (car will not start)
  • Non functional: (the car travels extremely slowly)
  • Reproducible:
  • Non-reproducible:


[All software has bugs.]


How to write good code:

  • Easy to read (Notation).
  • Robust/ functional.
  • Proceeded by planning.
  • Comments.
  • Well formatted, readable code.
  • Error handling.
  • Documentation.
  • “Brain sized” chunks.
  • Well tested code.
  • Understandable by others.


What do you need to design software?



  • Brain.
  • Pen and paper.


{NO computers, mood room or IDE.}


You CAN (not) do everything.



  • Use teams of people to split up work.
  • Use software tools to make the interaction easier.


Humans suck at doing stuff; computers suck at designing.


Tools for software development:



  • API’s 
[Application Programming Interface](Library of code for use).
  • Source control 
(controls additions to the source code, updates everyone's)(versioning; checking in-&-out; branching).
  • Build tools 
[compiler] (brings the code together for execution; turns a high level language into machine code)
  • Artifact control 
(keeps a compiled copy).
  • Documentation.
  • Bug tracking software.
(Prioritises issues and assigns tasks to correct the code; links with versioning)

  • Automated testing.
  • Continuous integration servers/ automated build tools 
(keeps track of everyone's addition and brings it together)
  • Automated deployment 
(,e.g: ios distribution).


Software development lifecycles:



Waterfall (traditional):
  • Requirements.
  • Design.
  • Code.
  • Test.
  • Deploy.
  • Support.
  • End of life.


Agile (the upstart):
Rough requirement.
Build something that works.
(but that is fully functional).
Refine the requirements.
Build something that works a bit better.


The computer does the testing.
“If the test fails give me a ring; if the test works don’t bother me.”


!xiety (Bangxiety) meter:



  • Designed to tell the user when the battery is going to run out.
  • Every system has inputs and outputs, even this piece of tech.


Some of the design challenges:



  • Reading the wheel speed.
  • Recording how much power the batter has used.
  • Key presses.

Wednesday, 1 October 2014

Knowledge based system answers


The three parts of a knowledge based system include:
  •          Collecting information from the user. (knowledge based)
  •          Returning  applicable information. (inference engine)
  •         Checking to see if the result is acceptable.  
  •      Stores data.(raw based)

For a doctor’s office help desk:

Information would be collected about the patient’s condition. The system would suggest a possible answer then check with the patient whether their results are legible or applicable to their situation.
A help desk could also use a knowledge based system to simply check appointments by having the user input their name or other patient information then receive an appointment time or doctor's information.