what's up y'all this is Hussein Nasser from IGeometry where we discuss
software engineering by example and this is our software engineering talk where
we pick a topic and do we just casually talk about it right and today's topic is
a user experience versus the API which comes first right any modern software or
application that you design always have these two pieces somewhere oh I mean
somewhere on the other right so must have these two pieces there's always a
back-end right where the API lives and there is a front-end consuming that API
in some sort whether that user experience is on a mobile phone or our
web right web page website or even Alexa like a voice-controlled user experience
touch augmented reality anything right the user experience there goes the
backend which is like a bunch of API is that the user experience consumes right
usually these are REST API most of the time okay so start defining those two
and then we'll talk about if you want to design an application what should you
start with if you do start with that back-end should you start start with
that front it right so let's get to it so the API what is an API maybe is a set
of suspense for application programming interface where you have a set of
methods or our functions or procedures that you can your application or your
consumer can call and get information out of it and then regardless what the
API looks like they be I could be a c-sharp application with a bunch of
interfaces right so you have an interface right or it could
be web based on the HTTP protocol rest or soap right I made a few videos on
rest and soap check out this or here I don't know I don't know but don't be
somewhere here yeah so so the API could be ridden any any kind of language right
and exposing any kind of protocol starting it back in the seventies where
it was just RPC remote RPC a core bond or that's kind of things and back until
today which is like REST API and even improving more making it more more
flexible using the graph QL model Facebook that develop like to make API
is much much much more flexible so REST API czar essentially the current modern
API architecture where it's based on the HTTP model stateless and we made a few
videos about stateless versus stateful what's the difference or a browser later
okay and yeah so it's based on HTTP protocol right and their return usually
is Jason which the consumer most consumers know how to understand how to
consume right applications right and then recently it's being changed to
protocol buffer because we realized hey I
ap eyes shouldn't really need to be human readable right so I can send
things in binary users won't consume the API immediately or directly and people
will basically write apps or clients that consume the other side from the
equation here is experience the user experience and the user experience could
be as we did discuss right it could be a simple mobile app with an ios and
android blackberry if you're still using these things right wait we have
microsoft fried tortilla windows phones now yeah web right website
voice-controlled alexa google home apple or with that
thing called on poet world what's what's called a forgot apple code pod no yeah
so the user experience is what consumes this API right not simple and you try to
build the user experience in a way that is so the user can get things done and
as few clicks or commands as possible right so that's a better user experience
right if the user clicks like seven times to print something right or get
something done then it's not really a good user experience but it is a user
experience regardless or not right it is a user experience all right so so that's
basically a user experience so now you have as a program as a software engineer
you're responsible to design both right some companies you there will be back
end design or API designer there will be user experience I personally think that
you have to be both right softer and you have to be empathetic and have to be
thinking about both sides of the coin here and build applications using both
models okay so a few so the question now after six minutes we get to the question
finally what should you start with should you start with the REST API or
the API first when you design your application or should you start with the
maybe the user experience first so let's explore both there there are no
right or wrong answers guys here so as always as always like what I call this
like straight off yeah straight off yeah between the two so let's start what if I
designed the API first so let's take an example first like guys I think it with
an example Nick things become more clear and let's start let's assume on building
ah the YouTube piece for viewing a user videos list of videos right so let's
start with that okay some I will click the user will click on something and he
will be or she will be able to list all their their videos essentially right and
they will be able to scroll and get more videos whatever so that's the user
experience so that's a requirement build a video API so let's assume we have two
database it's already configured and maybe not right so so maybe as it that
back in designer you are responsible to do that you are responsible to design
the database you are responsible to do that stuff so if I blindly someone told
me that right just videos go ahead right so if I started with the API first I
don't know I would build it in a very generic way because I have no idea I
have no requirements right I have no requirements I know that we're building
a video API where it could be like a an end point where I they use a request
slash user slash videos and there must be some authentication method I'm not
gonna worry about that but I will return essentially all the user video so now
the question is okay what should I have a turn what did it feed you what does it
feed you have no clue right this is a video ID description name title
thumbnail obviously they cause you start thinking right it's just like you start
thinking about the user experience but not really because you're worried about
how you're gonna build the tables at the back end whether you want to use a
sequel base database or no sequel base that is you you worried about all these
decisions that you have to mean you really don't care right about the user
experience right now right and you you if you work with companies you will see
this struggle fight between the back end guys and the front end guys and people
thinking oh we're the base right everybody is the best right nobody
thinks they're they're the best and essentially but essentially if you stop
that you're gonna build a very generic API right so I don't know maybe you're
gonna return everything right what are you gonna think okay for each and
everything are going to select the star which is very expensive to compute and
then all these questions right so you don't have much to go with if you start
with the video with the API first right you're gonna build a very generic way
and advantage of that you're gonna finish the API first right
and you might build it for multiple user experience
okay that's a good thing gonna finish fast you're gonna build it for multiple
user experiences okay and you try to optimize based on that
generic approach right say you'll build certain indexes but you still don't know
right what the user know so you start to add more stuff that's coming to the
disadvantage things you start to add more stuff that you don't really need or
the users might not even need all right do you return stuff that the user more
might not even need okay and or you might forget things that they use that
actually you want so you start building this API but it's blind just looks like
based on blind faith you go I'm gonna build this and let's see what they use a
watch right okay so there are advantages and
disadvantage for both right so you'll have a bit more freedom right you can
optimize right you're gonna build this generic zone for more multiple user
experiences but at the same time you'll have you might run into trouble with
once the user experience come to the place because there's experience might
actually need more stuff so you might read to redesign things at the future if
you start with the user experience then you're gonna define that's my user
experience if I click this I'm gonna show right and you're gonna see that I'm
biased towards the user experience first very clearly here but but again I'm not
posing my my opinion at all guys you can let me know what do you think that user
the comments below but if I you start with a user experience first then you
have the ability to define the requirements essentially right so I need
the video API right I need to click I need the thumbnail and in the title or
the description guess what I actually need to show write the number of likes
here okay and maybe the number of comments but not necessarily the
comments the list of comments of this video because I don't really care is II
see as a user experience you don't care about performance if you think about it
well that's not really true but you care about the user experience more right
versus the API you care about performance and imposing your queries so
is the user better here is the user experience better right as is the is the
user here is that what you call this like favor you favor the user versus the
API oh no so we'll think about right so it's like
okay I want the number of comments or maybe you can't show that comments for
each video is just doesn't make any sense right but you started loading all
these stuff and the videos and then he say okay I know number of lights on this
I just want as I start loading I can't load more than because I have
limited memory in mind like whatever application now this comes like to a
niche application my oil is I'm gonna reserve certain amount of memory and I
can't load more than 30 videos right like this 30 video is not the actual
blob of video are just talking about the actual description and names and
metadata of the videos now ahsoka I want to just load the 30 videos and as I
scroll or I want to query more all right so that I just defined I want 30 so
that's your pages right so so you just define paging you based on the user
experience right okay not thinking about performance you think about the mobile
device you're thinking about the coda of the mobile device you think about the
memory of the mobile device all these things and as you start scrolling you
start loading a lista now you take all this data that you collected that
requirement and then you push it to the back end and say okay guys or even you
right you you now design the API says okay this will this requirements I only
need the title and the name and the description and whatever I need this
information I don't need the rest of don't return it don't don't suffocate
the bandwidth for information that I'm not gonna use the user experience to
begin with her so that's the advantage is you will start optimize and make the
API efficient for that user experience here's the catch though if you made that
API custom to this user experience then my break on other user experiences right
so my work for this user experience which is the phone right but it might
break actually in the web or my other and urban in the desktop user returns it
doesn't work at all so you might need to tweak the API
differently right so you get you gain and you lose right so
which is best right which is best you start from the API or you starting the
user experience right there are advantages and disadvantages of both and
I'm gonna pass the question back to you guys
what do you think if you want to build an API or you've been a build
application what do you design first you design the API first or designer user
experience first right let me know the comment is the comment
below and that's that's all for us today and check out the other contents of this
channel we discussed software engineering by example we just got a lot
of software stuff in this channel and I'm gonna see you in the next one guys
you stay awesome bye