Advanced Web Programming
Advanced Web Programming
var x =3;
when we operate on this variable, javascript judges
whether x is a int or a string ....
var x =3;
var y = x * 4;//now javascript will judge that x will be an integer.
test yourself whether you
know what to tell with respect
one word
web -- http
html -- structure
css -- decoration, class
javascript -- nature of langauge and how it has changed
over a period of time...
alert("1");
but in javascript
{
var y = ?
return y; //what is y we may not know
}
function getPerimeter(length,breadth)
{
var perimeter =2(length+breadth);
return perimeter;
}
many a times we are very busy calling
other people functions and not writing our function
if we are calling other fucntion, then they decide.
what will be the input argument what will be return type
and what will be function name and our job is only
to call it, this is ok. but in a project what we are supposed
to do is come up with our own functions, here we should
show ability to get into details and justify our function design.
function areaofcube(length,breadth,height)
{
for example if i tell , please pass an array to a function and return the
sum of elements in the array. these kind of things we should be comfortable
in any programming langauge ....
always prove
1. input arugment reached the function
2. return type reached the calling function.
3. you can now think of logic building...
Object
state -- variables
behaviour -- functions.
for debugging in case we dont have sufficient data then we should not debug
we should put all our energy on getting the data...
how do i know why code is not working ... becuase still i dont have data
once upon a time, when javascript was creating lot of problems becuase
code was bad, browsers used to keep showing it on the screen, this was irritating
to the end customer so browsers in interest of customers started hiding
the problem thru some console messages, so now if we have to see why
the problem is coming we have to go to browser console and see what problem
we have...
sometimes while adding you will suddently see that things are concatenated.
that is becuase , some where a string has joined the party, then javascript
tells everything is a string
let to write functions which can take input arguments and return type
both in simple things like number, char and also arrays and objects.
let to write functions which can take input arguments and return type
both in simple things like number, char and also arrays and objects.
let to write functions which can take input arguments and return type
both in simple things like number, char and also arrays and objects.
people need patience to debug javascript code, and in initial stages we should
not look for shortcuts and undergo the process as we do assignmetns ....
but remember that in real life we use things along with a framework.
for example.
how do i do exception handling, in java, you need to know java syntax.
how to work on ready made DS in C++ or in Java, answer you need
to know javascript syntax.
how to give input to the array from the user. according to me as of now
this is waste of time, becuase we can use something equivalent of scanf
etc ... in real life dont bother too much of input and output becuase
you know 3 tier architecture, presnetation is a layer and not a function.
basic maths
1. what is input given -- array of numbers, it contains both odd or even
2. what is output expected. -- 2 numbers sum of odd, sum of even
3. do we know process how get output...
I will return an object which will two properties called evensum or oddsum.
....
I am looking at you from a 4 month of view, where how you write code
in multiple modules eventually leading to a project ....
people who look for only one way of doing things, are already in trouble
becuase in any design, things are non deterministic, that means
you can do things in multiple ways and still get correct result ...
most important take whatever you want, but justify and give reason
as to why you took at appraoch.
may be once you get a job you can meet the person who has asked
to code ds and hey tell me you asked me this ds question tell when did you
ds in your project this story is true for C world C++world or java world or X
world...
interview guys ask ds so that can club multiple questions into one.
for example I dont want to ask ... do you for loop, do you if...
moral dont know how to create ds that is ok. but dont know how to use
ds that is pathetic...
DS -- group, operations.
in javascript you will see writing semi colon is optional if you are starting
a new line but dont do all these things, just make a habit of writing
semi colon after every statemenet, similarly use { } liberally
if somebody something is slow, you should ask tell me how much time it look
you changed the code, it is fast, tell me how mcuh time it takes.let us
get data and then interpret it and not simply keep telling it is fast, it is slow.
it is good practice .... this is not science..
become a fan of problem solving rather than java or javascript or .net ...
usually what i have observed when i give problem on array or some object
or some ds and tell do ths problem in javascript, they will tell i have a problem
then when you ask them to do the problem in c+= there also they will
get a problem or java, there also ....
but those observed must have seen, that i did not get this programworking
with just one go... I had look at the output of the program multiple times
to make it working
for example first time, i just proved that input argument is got and return
type from teh function is working ....
whenever we write code we should ensure we check the output multiple times.
I have told couple of people while coding, I would just sit and watch a like
mute spectator with no comments as to how they will code, they tell no.
these 3 are most basic things for any person to know if he is calling
a function.
when I ask people how do you know printf in C fails. answer you should
read documentation, that is only way to know I read documentation of print
only then i will come to know print returns an int.
real life job we have to justify our quality as a programmer thru data.
some of the data points you an consider is
1. your ability to choose functions and how you relate to them in terms of usage.
object...
how do you create an object in javascript. this looks like a shocking thing
most of times especially for people from C++ and java backgrounds why..
when i multiple ways, use which ever you want but consistantly and show
and justying the reason why you wrote code that way only. that is important
easy to say and most important it should be done ....
}
if you have to do this, in java, you should first create a class and then
create an object, here we can directly create an object without a class.
javscript is object based langauge
again observe basic things, I never want to createa function before calling it
i want go guarantee myself that a function has always been called before
being created.
that brings clarity as to what to write inside the function.
whenever you create an object pepole have a tendancy to ask to which class
this is wrong thing in javascript, you can have object without a class
again the appraoch, whether you deal with object, simple data type
array or datastructure, approach of how you look at function should
be same.
1. prove input argument is got
2. return type reaches...
this should become our national anthem for our batch ...
later on once we meet in person in CDAC then we will do one more recap
on OO, why i said is, becaue lot of people people talk about OO and when
you observe their code there is hardly oo concept use it will like c code
where structure has been replaced with classes. this is not OO.
there can be different styles of code, what i want to show you
some javascript code which uses objets and if you attempt same thing
in java or in c++ you yourself will able to see how syntax changes ...
moral of the story remains same, in any langauge you should be good
at function design, data types, basic, array , objects and datastructures
we should know how to pass it and how to return it from functions.
my english is not all that great, so tolerate, my grammar is even more poor
feel free to let me know in case my sentence is not correct ....
I hate using powerpoint slides or ready made programs most of timesin the beginning
later on ..
simple question ..
we have a box, and nobody is going to use it. in that case what is good
to put inside the box, a watch, a diamond or a garbage etc.. nothing makes
sense becuase nobody is going to use it.... you should not even touch the box.
this is how our html is as of now.
becuase we did not use javascript, becuase we did not use server side
all things like value name id all are useless as of now once we start
using server side you will see the value of name, once you
start using client side then value of id...
theory told you to invoke form action, you need a submit button and not
a normal button.
file:///C:/Users/vasul/Documents/Zoom/2020-04-14%2014.28.43%20DAC%20KP%20CDAC
%20Bangalore's%20Personal%20Meeting%20Room%207395131973/notes/assignments/a03.html?
file:///C:/Users/vasul/Documents/Zoom/2020-04-14%2014.28.43%20DAC%20KP%20CDAC
%20Bangalore's%20Personal%20Meeting%20Room%207395131973/notes/assignments/a03.html?
I dont want you to hear the word called id and name first time
when we start javascript and php hence it was covered.
file:///C:/Users/vasul/Documents/Zoom/2020-04-14%2014.28.43%20DAC%20KP%20CDAC
%20Bangalore's%20Personal%20Meeting%20Room%207395131973/notes/assignments/a03.html?
x=abc&y=def
file:///C:/Users/vasul/Documents/Zoom/2020-04-14%2014.28.43%20DAC%20KP%20CDAC
%20Bangalore's%20Personal%20Meeting%20Room%207395131973/notes/assignments/a03.html?
if you observe if you use id, information will not go via post or get to
whereever you are sending
but if you use name it will go.
file:///C:/Users/vasul/Documents/Zoom/2020-04-14%2014.28.43%20DAC%20KP%20CDAC
%20Bangalore's%20Personal%20Meeting%20Room%207395131973/notes/assignments/a03.html?