When to use client-side or server-side? [closed] - client-side

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I just finished an intro to web dev course in my CS program and came away wondering something simple. When should you use JavaScript (client-side) instead of server-side (we used PHP but anything applies) code? Vice-versa as well.

There is no recipe for deciding that. A few notes:
security and validation should always be present at the server side (sometimes duplicated in the client).
the client-side should contain only UI-logic. No business logic.
logically, everything that accesses a database should be on the server.
Of course, if your application is a RIA (rich internet app), then you can have logic on the client. So it all depends.

Javascript should be only used to manipulate the UI of the page. You can also do certain validations using it, however, there must be corresponding validation on the server-side. For doing any data manipulation, applying business logic, etc you should always use server side code.
Here are some cases where you will use client-side code:
Changing the look (UI) of the page e.g. dynamically show/hide some
elements
Validate user inputs (this should also be done on server side)
Cases where to use server-side code:
Validation of user inputs (should always be done on server side irrespective of whether done on client side or not.)
User authentication
Business logic (deciding what to show to which users, calculations)
Database access

Imho i would say, use server-side if you can. All client-side code can be manipulated. Or maybe will not run cause the browser dont support it.

Related

what is single page application? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
what is SPA( single page application ) ?
i'm use to react by 'create-react-app'
that is SPA ?
The simplest answer is an SPA or Single Page Application is a web app that loads a single HTML page and all the necessary assets (such as JavaScript and CSS) required for the application to run. It then uses dynamic techniques (AJAX) to update just parts of that page, instead of making a round trip to the server to create new pages.
A benefit is that you only transfer the minimum amount of data needed to make the update changes after the main page has been loaded. The main page loads all the content (js, css, etc) that the SPA needs to run so the initial page load can take longer, but after that it is very fast.
Popular ways to handle the dynamic content aspect is with frameworks or libraries like Angular or React that handle a lot of the frontend heavy lifting.
Yes, 'create-react-app' is a tool for creating a React SPA.
Not sure if I'm understanding your question correctly but...
A single page application is a way of using React that uses various 'views' instead of different pages. This is advantageous because it prevents using page redirects and page reloads which makes page navigation simple and efficient.
'create-react-app' can be used to create a SPA or a non-SPA depending on how your organize your code.

What is the standard way of having constant content (headers, footers, sidebars) across a website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've just started web programming, but I can't find anything about how to define an html element (the best example is probably a header, like the one at the top of stackoverflow) in one file, and use it in every part of your website.
I've read something about frames, but they're deprecated; using JQuery to dynamically load content, but that would look shabby as JQuery only runs after the rest of the document has loaded; and some sites even seem to have their headers actually written out on each page, which seems like a waste of time.
What should I be doing in this case?
Php include may help you (link below)
PHP Include Files
Your code would look something like this:
<html>
<body>
<?php include 'header.php'; ?>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
</body>
</html>
Usually you have the server generate the response page on the fly and append the headers at response time using something like JSP or PHP. You can still use frames if you really want. You can also use JavaScript to pull in content on the page as well. However, this is not exactly good practice because if the user has JavaScript disabled, they will see no header. The server side appending is more accepted because it doesn't depend on what the client has enabled.
This is usually done on the server either with Server Side Includes in Apache (not requiring use of any server side language) or with the server side programming language of your choice - usually either using the concepts of page templates, sections, partials or includes (or a combination thereof).
PHP has the Include function, which has already been mentioned, ASP.NET web forms have Master Pages and User Controls, and ASP.NET MVC has layouts and partials. I imagine Ruby on Rails, Java Server Pages and any other server side frameworks will have similar constructs for common layout templates and shared content between pages.
The point is that there are at least as many methods of constructing pages with shared or common elements as there are frameworks for building pages - but no method involves "just" HTML.
Find the right one for you.

Form Input Validation with Meteor [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Meteor doesn't have a built in validation smart package yet. What validation libraries should I consider? What are other people using?
We decided to use simpleSchema with Collection2 and autoform for validation. It's a very sophisticated solution. We save a lot of time using this approach rather than trying to roll each form by hand.
Simply by defining a scheme with validation rules (validation rules are provided automatically for data type and isRequired settings) then creating a form with autoForm (a single line of code) and you get all this for free
An autogenerated form that uses bootstrap3 classes.
Appropriate HTML5 fields for all keys in your collection schema.
A submit button that gathers the entered values and inserts them into your collection.
Form validation based on the schema attached to your collection. By default the form is validated when the user submits. If anything is invalid, the form is continually re-validated on keyup (throttled) as the user fixes the issues.
Default validation error messages that appear under the fields, and can be customized and translated.
meteor-simple-schema
A simple, reactive schema validation smart package for Meteor.
https://github.com/aldeed/meteor-simple-schema
meteor-collection2
A smart package for Meteor that extends Meteor.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating. Also adds support for virtual fields.
https://github.com/aldeed/meteor-collection2
meteor-autoform
A smart package for Meteor that adds UI components and helpers to easily create basic forms with automatic insert and update events, and automatic reactive validation.
https://github.com/aldeed/meteor-autoform
If you want to use meteorite, you can just search through the atmosphere packages to see what's popular. I'm currently using jqBootstrapValidation. In the past I have used validate.js, but right now I prefer to have something with bootstrap integration. I hear parsley.js is popular with the cool kids, though as of this writing there isn't a smart package for it - but that's easy enough to solve.
You already have Tracker as part of Meteor, so I put a little tutorial and JSfiddle together on how to use it to implement a typical form validation scenario.
http://bit.ly/meteor-form-validation-video
http://bit.ly/meteor-form-validation-fiddle

How to customize web-app (pages and UI) for different customers [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
We have an ASP.NET web-application which has become difficult to maintain, and I'm looking for ideas on how to redesign it. It's an employee administration system which can be highly customized for each of our customers. Let me explain how it works now:
On the default page we have a menu where a user can select a task, such as Create Employee or View Timesheet. I'll use Create Employee as an example.
When a user selects Create Employee from the menu, an ASPX page is loaded which contains a dynamically loaded usercontrol for the selected menuitem, e.g. for Create Employee this would be AddEmployee.ascx
If the user clicks Save on the control, it navigates to the default page.
Some menuitems involve multiple steps, so if the user clicks Next on a multi-step flow then it will navigate to the next page in the flow, and so on until it reaches the final step, where clicking Save navigates to the default page.
Some customers may require an extra step in the Create Employee flow (e.g. SecurityClearance.ascx) but others may not.
Different customers may use the same ASCX usercontrol, so in the AddEmployee.OnInit we can customize the fields for that customer, i.e. making certain fields hidden or readonly or mandatory.
The following things are customizable per customer:
Menu items
Steps in each flow (ascx control names)
Hidden fields in each ascx
Mandatory fields in each ascx
Rules relating to each ascx, which allows certain logic to be used in the code for that customer
The customizations are held in a huge XML file per customer, which could be 7500 lines long.
Is there any framework or rules-engine that we could use to customize our application in this way? How do other applications manage customizations per customer?
If your regular data is held in a database I'm not entirely sure why you'd want to have all of that customer specific information in an xml file. Move it into the database.
Next, there are many different kinds of rules engines out there. Considering you're using asp.net you might want to look at Windows Workflow for at least some of this. You might read the following: http://karlreinsch.com/2010/02/05/microsoft-rule-engines/
A long time ago I used a product called Haley Rules to drive a c# web app. It controlled everything from the screens that were available right down to the fields that appeared and whether they were required or not. It took awhile to get the team on board with how it worked, but once that happened bringing on a new client was extremely simple. Haley was since gobbled up by Oracle, but was probably the absolute best one out there.
Others you might be interested in are NxBRE and even nCalc. NxBRE is an actual rules engine which is a port of one built for java. nCalc on the other hand isn't a rules engine per se. However, if you can express your logic in simple boolean statements then it is extremely fast. I'm currently using this to drive page flow in one of our applications.
Some commercial ones include: FlexRule, iLog
Your existing rule engine tool supports your web application, which means it meets your needs already. You can use other "Rule Engine" like MS work flow, but IMO it can also end with a hard to maitain situation.
Let's say there is registration portal. It collects general user infomation and save them into database. Simple. we build one protal for one client with several ASCXs and Rules.Then for another client,we add more rules and more controls to these ASCXs. Working in this way, sooner or later we will reach the final straw client. At that time the code base is hard to maitain and devs lost themselves in lots of rules. It is what happened to me.
So to me, it is not about which Rule engine to use.
Then How?
I have raised a question, and one of the answer makes sense to me( thought not a picked answer). In this answer, the guy mentioned what kind of company you are. In your question it is more like which department you are or do you want to seperate your dev teams.
If you are in a archetect teams, build a framework with a rule engine. Create a basic registraion portal as a sample portal.Make DAO,BO decoupled with UI (Seperate layers).
If you are in a customise teams, create customised user control (dont reuse these user control in basic version). What you will recreate is just UI, you can still use DAO,BO as they are not defined in user control, they are at other layers. In this way you get the freedom to define your client specified rules without worring about contaminating other clients rules or introducing new bugs to other client's registrations.
Just realise it is not like an answer to your question. Anyway it is my thoughts after limited xp of working on a engine rule based ,multi-clients web application.

Network traffic with standard ASP.NET applications

I've been learning about AJAX and jQuery to build web applications and now I see how powerful are these tools. Because this, some questions about the network traffic gennerated by standard ASP.NET applications without those techniques came up.
It is known that every control that has the runat="server" property setted, puts on the viewstate it's current values, which is codified and placed inside a hidden input on the response to the user.
However, every little action on the page triggers a post to the server, sending back the entire page's values. Depending on the complexity of the page, it may be very dangerous to the application because it would generate a lot of traffic unnecessarily.
An example: i've build a page that it's size is about 155kb rendered (62kb only is the viewstate). So, every post on the page returns a new rendered page with similar size, even it's contents does not changed. Inside an Intranet environment, it seems nothing, but on the web it would be inappropriate.
What do you think about this question? Am I wrong?
My opinion is that if you don't like the purely server-side nature of vanilla ASP.NET, you should just include the very techniques you mentioned. There is lots of documentation and many step-by-step guides to help you understand how to use a mix of client side and server side techniques with ASP.NET.
What do i think about this question? Which question? I'm not sure you have a question other than your question about your mystery question.
I'll just leave this here: http://www.asp.net/ajax

Resources