Compare of Django and SSH - bernardopnunes/SoftwareEngineeringSDUW GitHub Wiki

Group:Seven Dwarves

Overview

Django

Django is an open-source framework for Web development. And the underlying code was written in Python. In 2005 July, Django was published in the permission of Berkley Software Distribution (BSD). Also, Django is aiming to develop a database-driven website in a simple, sharp, and agile way. What is important to Django is code-reuse. Many components can serve the whole frame with the form of plug. At the same time, Django has tons of powerful third-party plugs you can use.

SSH

SSH is an integrated framework of struts+spring+hibernate, and it is a kind of framework set that will be used in most software design process now. This framework is based on the development of MVC, and MVC pattern has become a common pattern in modern J2EE development, and more and more developers like JSP and PHP welcome it. MVC pattern, Model, View, Controller.

The advantages of Django

Powerful database

CapabilitiesIn pyhon class inheritance, a few lines of code can have a rich, dynamic database operation interface (API), if necessary, you can also execute SQL statements ORM (Object Relational Mapping "object-relational Mapping"), it implements the data model and database of decoupling, namely the design of the data model does not need to depend on the specific database, the database through simple configuration can be easily replaced.

Comes with powerful background functions

Write the code to implement the function in admin.py, and a few lines of simple code can realize your dream of being an administrator.No need to worry about the design manager anymore!

Elegant website

In urls.py, you can use the regular matching url, pass it to the corresponding function, define it yourself, and the url can be whatever you want it to be, whatever you want it to be.(note that regex is a separate syntax, not one language's own.)

Templating system

Templating systems greatly reduce the chance of developers getting a headache.Because the templating system design is simple, easy to extend.Code, style design separately.Find clearer, easier to modify!

Caching system

Django works with memcached, redis, or other caching systems to speed up page loading.Let the user experience degree is better!Functions in the templates folder views. Py render Html templates in templates to get a web page with dynamic content, but you can use caching to speed things up.

Internationalization

It's hard not to go international with something this good.Want the page to display in different languages, such as Chinese, English, and many other languages.You just need to change it a little bit in the Settings of a file.The page will be dressed in a variety of languages.

Django has a good App concept

App pluggable, is a rare idea.Do not need, can be deleted directly, the impact on the system is not big.How's that?Is Django as powerful as you can imagine?But don't get too excited.Because the code still needs to be written, it's just faster and more convenient to use Django to develop your website

The advantages of SSH

The advantages of Struts

  1. implement the MVC pattern with a clear structure, so that developers only focus on the implementation of business logic.
  2. it has rich Tag library. If it can be used flexibly, the development efficiency can be greatly improved.
  3. page navigation makes the context of the system clearer.Through a configuration file, can grasp the whole system between the various parts of the connection, which has great benefits for the later maintenance.
  4. provide Exception handling mechanism. 5.database link pool management. 6.support application internationalization.

The advantages of Spring

  1. Spring effectively organizes your mid-tier objects, whether you choose to use ejbs or not.If you're just using Struts or another framework made for J2EE apis, Spring is working on the rest.
  2. Spring eliminates the overuse of singletons that is common in many projects.In my experience, this is a big problem, and it reduces the testability and object-oriented aspects of the system.
  3. by handling configuration files in a consistent way across different applications and projects, Spring eliminates the need for properties files in a wide variety of custom formats.
  4. by reducing the cost of programming to interfaces rather than classes to almost nothing, Spring can promote good programming habits.
  5. Spring is designed to make applications created with it as little as possible dependent on its APIs.Most business objects in Spring applications do not depend on Spring.
  6. applications built with Spring are easy to unit test.
  7. Spring can make the use of ejbs an implementation choice rather than an inevitable choice of application architecture. You can choose to implement the business interface in POJOs or local EJBs without affecting the calling code.
  8. Spring helps you solve many problems without using ejbs.Spring can provide an alternative to ejbs that are suitable for many web applications.For example, Spring can use AOP to provide declarative transaction management without the EJB container, if you only need to work with a single database, or even a JTA implementation.
  9. Spring provides a consistent framework for data access, whether using JDBC or O/R mapping products (such as Hibernate).

The advantages of Hibernate

  1. hibernate is an open source framework based on ORM technology, which encapsulates JDBC in a lightweight way and USES object-oriented ideas to manipulate the database.
  2. hibernate provides session caching and second-level caching, which improves performance for systems that do not need complex queries.
  3. use Hibernate, good portability (as long as you use Hibernate standard development, when changing the database, you only need to configure the corresponding configuration file, do not need to do other tasks).
  4. Hibernate implements transparent persistence.When you save an object, it doesn't need to inherit any classes in Hibernate, implement any interfaces, and is just a pure POJO object.
  5. Hibernate is a lightweight framework without intrusion.
  6. You don't need to manually write SQL statements (you don't need to edit JDBC), you just need to manipulate the corresponding objects to store, update, delete, load, and increase productivity.
  7. Hibernate code testing is convenient.

Summary of the advantages of SSH framework

  1. A typical three-tier architecture embodies the idea of MVC(Model, View and Controller), which can relieve developers of the burden and effort of re-establishing solutions to complex problems, facilitate agile development of new requirements, and reduce the development time cost

  2. Good scalability. The mainstream technology of SSH has a strong user community to support it, so the framework is highly extensible and pluggable for special applications to avoid most functions that cannot be realized due to technical problems

  3. Good maintainability, the business system often has new requirements, the three-tier architecture can minimize the risk of requirement modification due to the reasonable separation of the logic layer and the presentation layer. With the popularity of new technologies or the aging of the system, the system may need to be reconstructed, and the success rate of SSH architecture reconstruction is much higher than other architectures

  4. Excellent decoupling, few software products demand is completely right from the start of a fixed customer software requirements, is with the deepening of the software development process, keep clear, therefore, often meet with software development to a certain extent, because the customer changed demand for software, making the realization of the software had to change the SSH three-tier architecture, control depends on the business logic layer, but not with any specific business logic component coupling, only with the interface coupling;Similarly, the business logic layer relies on the DAO layer and is not coupled to any specific DAO components, but is interface-oriented programming that implements the software in this way, even if one part of the software changes, the rest does not.

The disadvantages of Django

High integration

Django also includes some functional modules that are not needed for lightweight applications. For lightweight development process, it is not as light as flask.

Over encapsulation

Django encapsulates many classes and methods. It can't see the internal code directly. It's easy to use directly, but it's difficult to change.

Performance disadvantage

Compared with the performance of C and C + +, Django has low performance. Of course, this is the impact of Python language. Other Python frameworks will have the same problem when the traffic increases to a large enough size.

Template problem

Django's template realizes complete separation of code and style, and does not allow Python code in the template, which reduces the modifiability of the template. For some programmers, flexibility may not be enough.

The disadvantages of SSH

The disadvantages of Struts

  1. When you go to the presentation layer, you need to configure the forward. If there are ten JSPS in the presentation layer, you need to configure the struts ten times, and do not include the change of directories and files. Sometimes, you need to modify the forward again

  2. Struts Action must be thread-safe, which allows only one instance to handle all requests. So all the resources used by the action must be synchronized, which raises the issue of thread safety.

  3. Testing is not convenient. Each Action of Struts is coupled to the Web layer, so its tests depend on the Web container and unit tests are difficult to implement. However, there is an extension to Junit, Struts TestCase, that implements its unit tests.

  4. Type conversion. Struts's FormBean, which treats all data as a String, can be converted using the commons-beanutils tool. But its transformations are all at the Class level, and the types of transformations are not configurable. It is also very difficult to return the error message to the user during type conversion.

  5. Reliance on servlets is too strong. Struts must rely on ServletRequest and ServletResponse to handle actions, so it cannot get away from the Servlet container.

  6. Front-end expression language aspects. Struts integrates with JSTL, so it mainly USES JSTL's expression language to fetch data. However, JSTL's expression language is weak in handling Collection and index properties.

  7. Difficult control of Action execution. Struts creates an Action that is difficult to control the order in which it is executed. You may even have to rewrite your Servlet to fulfill your functional requirements.

  8. Pre - and post-action processing for actions. Struts processing when the Action is based on the class hierarchies, it is difficult to operated in Action before and after processing.

  9. Insufficient event support. In struts, a Form corresponds to an Action class (or DispatchAction). In other words, in struts, a Form corresponds to only one event, which is called an application event. Compared with component event, application event is a coarse-grained event.

The disadvantages of Spring

There is a lot of code to write in JSP, the controller is too flexible, and it lacks a common controller

The disadvantages of Hibernate

  1. Hibernate is expensive to learn.

  2. Not suitable for complex SQL queries (statistics).

  3. It is not suitable for batch operation of data (add, delete, look and change for a single object).

A comparison between the SSH framework and the Django framework

  • The Django framework is much more popular than the SSH framework.

  • The Django framework implements more flexibility than the SSH framework.

  • The SSH framework is based on the Java programming language, and the Django framework is based on the python programming language.

  • The SSH framework uses the MVC design pattern, and the Django framework uses the MVT design pattern.But MVT is yet another design pattern similar to MVC. It is also used for implementing web interfaces and applications but in contrast to MVC, the controller part is taken care for us by the framework itself.

  • Django has a powerful database access component. Django's Model layer comes with a database ORM component, so that developers can operate the database without learning the SQL language. But SSH requires a high level of familiarity with database statements.

  • Django's error prompts are detailed enough to make it easier to know about errors.

  • Django is a Python Web framework for perfectionists with development time constraints. Django provides a fully functional model-view-controller framework. It is developed on a built-in battery approach (Django comes with a full suite of tools that work right out of the box), enabling developers to create Web sites without third-party libraries and tools.Therefore, the development of SSH framework is more complex and time-consuming.

Reference

  1. https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django
  2. https://realpython.com/tutorials/django/
  3. https://blog.csdn.net/ycclydy/article/details/80451571
  4. https://www.cnblogs.com/wuxiang/archive/2014/03/01/3574980.html
⚠️ **GitHub.com Fallback** ⚠️