Sei sulla pagina 1di 17

Task 1- Explain the key features of event driven programs

Service Oriented- this is providing a service to the user when need for
example when an USB device is plugged into the system and it does the
work for you or when you receive an email. They often appear in the
background and have no user interface to use but all have the ability to be
stopped and started at the users will. Programs like Bluetooth and
Autodesk functions are constantly using your memory for background
programs.

Time Driven- Time Driven programs such as anti-virus scans, task


scheduler and operating system updates are important features in running
your pc. There is usually an anti-virus scan every day around 1.oo in the
morning to make sure there is so attacks to the system. A timer (clock)
triggers the event to happen. Another example would be that there could
be a system backup at 6.00 in the evening every Friday afternoon.

Event handler- Event handlers within programming are sections of code


that is run when the event has been detected. Example when a button
(btncalculate) has been clicked so basically it is the code behind the
button. Any event that is created there will always be a code behind it.

Trigger functions- trigger functions are called when an event takes place
e.g. button click, they are used to identify which event handler should be
run after a trigger has taken place. For example after a button has been
clicked they tell the system to run Private void btnNext click (object
sender, eventArgs) which is the event handler.

Events- these are the actions that cause the code to be called. Events
can come from the user or often from other sources e.g. timer, computer
boot up etc. example on a form: mouse clicks; keyboard press (up/down).

Event loops- this is when the processor is continually checking for


events. The computer works in milliseconds so 1 second is 1000
milliseconds and the computer will be checking many times each second.
When an event is detected, the trigger function is called, which calls the
appropriate event handler.

Flexibility- a wide variety of programs can be written for many different


application e.g. a program for a burglar alarm to an announcing package.
Event driven programming provides a very intuitive interface e.g. people
will find it easier to click a button, rather than type in commands such as
load program name run program name
It is easy to modify the code in an event driven program.
The programmer has a wide range of events available which gives them
greater control over how the program should respond to specific triggers
and as a result of those triggers what the code should do.

Suitability for graphical interfaces


Event driven programming is at the core of graphical user interfaces due
to the range of event commands that are available and are very
compatible with graphic interfaces e.g. mouse over, keystroke, click or
touch.
Event Driven Programming provides the functionally to the GUI.
(I.e. the `code behind` the button or the combo box)
With the advent of mobile phones/tablets (touch screens) new events
have been added e.g. pinch, swipe and slide.

Simplicity of programming
A lot of the code for the GUI is generated automatically, when the
programmer drags and drops controls onto the form
The overall problem can be broken down into the events that are to be
recognised so the programmer can be broken down into the events that
are to be recognised so the programmer can concentrate on writing code
for that event handler e.g./ private void btncalculateclick (object sender,
EventArgs e)
The programmer can double click the button and the code is placed
`behind` the button. The IDE automatically generates the event handler
stub. This saves on syntax errors and makes the coding process much
simpler.

Ease Driven Programming makes development makes developer makes


development much easier as the programmer can drag and drop the
controls (textbox, button radio, radio button etc.) onto the from .

Code can be edited easily.


Integrated Development Environment (IDE) (VISUAL STUDIO) provides
intelligence this helps to avoid syntax helps to avoid syntax errors
The Properties window allows the programmer to set and change the
properties of objects easily.
Easy to test as you develop not all the code has to be written before the
program can be tested, programmers can test each event handler
independently. This is in line with top-down development.

Task 2 (M1)

Discuss how an operating system can be viewed as an event driven


application
The first example of an event within an operating system is the initial
start-up process which is triggered by pressing the power button. The OS
is loaded into memory.
The OS has to handle any user interactivity e.g. (double) clicking icons
resizing Windows etc. In any order the user carries them out this is what
makes event driven the best way to develop an Operating system.
Some typical operating system actions that show examples of event
driven programming include.
1. Events generated by the user via the GUI such as

Clicking an icon
Moving an icon
Dragging a window
Resizing a window
Dragging and dropping a selected item
Clicking on a menu item
Minimizing or maximising a window

The OS has also to deal with the effect of the user interaction e.g. rightclick on the desktop the OS will show a floating menu.

If the user double clicks on a file to open it, the OS will firstly open the
application that the file is associated with e.g. myWork.doc open MS word

Resizing a window/minimising/Maximising

The OS handles keyboard events many of which it will pass to the running
application such as word while others are handled by the OS ctrl+ Alt+ del

2. The Operating system recognises and responds to Hardware events


Printer jam > inform user
USB pen inserted into USB slot (Auto play)
Inserting a CD
Power off switch
3. The operating system also deals with memory management.
Whenever a program is run, portions of memory will automatically

be to allocated to the program and then when it is no longer needed


it will be freed for reuse.

4. In addition the operating system has a list of free disk space for the
hard drive, do it is able to keep track of all the disk blocks which are
not in use by any file.

Task 3
Evaluate the suitability of event driven programs for nongraphical applications
e.g. Industrial systems
Air conditioning
When the user presses a button or turns a dial to the desired temperature
that is an event. Then sensors detect the current temperature which is
also an event.

Smoke Alarm
The sensor constantly monitors (takes reading every few milliseconds)
(time driven-event)
If smoke is detected the alarm is activated which is an event.
If the alarm is on and no smoke is detected, it will switch of which is an
event and by testing the alarm the user pushes the test button alarm
sounds which is also an event

Burglar Alarm
Contact switches (contact is broken when door or window is open) Light
beams (PIR) (EVENT).When the light beam is broken (event) a signal can
be sent wirelessly to the central panel. When the light beam is broken
(event) a signal can be sent wirelessly to the central panel. Alarm can
then be sounded which contacts the security company. Once the security
company are aware of the situation they then contact the home owner.
Once that happens the user enters a code to switch the alarm of.

Washing Machine
When the user clothes in the machine they close the door and then they
select a washing programme (cycle). Then the machine opens a water
inlet valve and when enough water has entered (based on weight) the
valves closes.
The water heated and the temperature sensor checks the temperature
and switches off the heater. The wash cycle is activated. The display
shows the time remaining.

Elevator
When user presses a button to call the elevator either up or down that is
an event or when the elevator arrives at a floor when the doors open also
an event. If the user enters the lift and selects a floor the button will light
up to show which floor has been selected or when the doors close it is an
event but will not close if blocked. When the elevator moves to the next
floor and it will only stop if it has been called or a user has selected that
floor which is an event. If the elevator is stuck and someone presses the
alarm for help it will alert someone at the desk.

Conclusion
Non graphical application can be events such as embedded systems
which can be smoke alarms, elevators and washing machines have events
that are not graphical and require event driven programs to control them.
Event driven programming is suitable for non-graphical applications. This
can be from a push or a button or turning a dial to change the

temperature in a room. Sensors can be events because when everything


there is smoke in a room the smoke alarms will go of anyway.

Task 4
Explain the main features of the following programming languages
C#, VBA, ColdFusion

C# is an elegant and type-safe object-oriented language that enables


developers to build a variety of secure and robust applications that run on
the .NET Framework. You can use C# to create Windows client
applications, XML Web services, distributed components, client-server
applications, database applications, and much, much more. Visual C#
provides an advanced code editor, convenient user interface designers,
integrated debugger, and many other tools to make it easier to develop
applications based on the C# language and the .NET Framework.

VBA which stands for Visual Basic for Applications, is a programming


language developed by Microsoft. VBA is a tool that people use to develop
programs that control Excel. VBA can be used for inserting a text string,
creating a custom command, creating a custom tool bar, menu etc. VBA
can allow you to create macros or small programs that perform tasks
within the application.

ColdFusion is a program for developing web applications. ColdFusion is


most often used for data driven websites or intranets but can also be used
to generate remote services such as Flash remoting. There is lots of
different additional features that it can handle such as server clustering,
GUI administration, conversion from HTML to PDF and simplified database
access. ColdFusion is built on Java and data is held in variables.

Task 5
Login
Variable Name

Data Type

Staff Array

Array of strings

Scope
(local or global)
Global

Login Count

Integer

global

Variable
Name

Data Type

Order total

double

Scope
(local or
global)
global

Burger cost

double

local

Topping cost

double

local

Drink cost

Double

local

User for
Holding staff
login names
Counting the
number of times
the user has
tried to login

User
for
Keeps the
total cost of a
customers
order
Keeps the
total cost of
the burgers
Keep the total
cost of the
toppings
Keeps track of
the total cost
of drinks

Login Form
Ask user to enter their username exists
Search the staff array to find if the username exits
If found:
Tell User login was successful
Close Login form
Go to Menu form

Inform user Login was unsuccessful


If (login Count ==3)
Inform user 3 chances are up
Exit
Endlf

Order burger Main Form


User selects the burger they want
User selects burger size

2oz 4oz 8oz

User selects toppings

Onions, ketchup Bacon, cheese, coleslaw

User selects drink coke sprite, Diet coke, Fanta (only one)
User selects place order.

If (2oz selected)
Burger cost = x.xx
Print burger size and xx` on receipt
Else if (4oz selected)
Burger cost= x.xx
Print burger size and xx` on receipt
Else if (8oz)
Burger cost x.xx
Print burger size and xx` on receipt

If(onions selected)
ToppingCost += 0.80
elseIf(cheese selected)
ToppingCost += 0.80

elseIf (Ketchup selected)


ToppingCost += 0.80

elseIf(coleslaw selected)
ToppingCost += 0.80

If(Coke selected)
drinkCost = 1.20
elseIf(diet Coke selected)
DrinkCost = 1.20

If(drink selected)
drinkCost = 1.20
elseIf(sprite selected)
DrinkCost = 1.20

If(drink selected)
drinkCost = 1.20
elseIf(fanta selected)
DrinkCost = 1.20

Potrebbero piacerti anche