没有框架的MVC?(MVC without framework? [closed])

编程入门 行业动态 更新时间:2024-10-25 14:26:03
没有框架的MVC?(MVC without framework? [closed])

现在我没有任何具体的问题,而是一般性的,征求意见。

在一个月内,我们将收到我们必须开发的项目的文档。 该网站具有很大的潜力,并将在电视和广播中做广告。 所以它会有很多访问者,成员,它会有一个丰富的管理面板,有很多选项。 我的朋友被要求担任首席技术官,是一位资深的PHP开发人员,拥有近10年的经验,我是一名初级JS开发人员。 (或更少,我没有多年的JS经验,但我承诺)

JS MVC框架是否替代PHP? PHP MVC框架是否替代JS? 它们是否都能很好地协同工作,或者是否可以不使用任何框架,而是以MVC方式编写项目?

例如:

型号:PHP controller:JS(jQuery + Ajax) view:HTML,CSS

由于我的朋友是一名专业的PHP开发人员,并且旁边会有日常工作,但只是在这个项目的开头,他并不真的想学习其他语言(比如Node.js),因为几乎所有的东西都是常规的对他来说现在用PHP。

我知道一切都取决于文档和我们必须完全开发的东西,但我只是一个好奇的想法,想要了解更多。 我知道我有很多东西需要弥补,有时候我会担心我目前的知识,但是我认为无论挑战多大,总会有一个解决方案。

Now I don't have any specific question, rather a general, ask for opinions post.

Within a month we will receive the documentation of a project we have to develop. The website has a lot of potential and will be advertised in TV and radio as well when it'll be done. So it'll have a lot of visitors, members and it'll have a rich admin panel with lots of options. My friend who was asked to be the CTO is a senior PHP developer with almost 10 years of experience and I am a junior JS developer. (or less, I don't have years of experiences in JS, but I'm committed)

Is a JS MVC framework substitute for PHP? Is a PHP MVC framework substitute for JS? Are they both working well together or is it possible to not use any framework, but write the project in MVC approach?

For example:

model: PHP controller: JS (jQuery+Ajax) view: HTML, CSS

As my friend is a professional PHP developer and will have a daily job next to, but only in the beginning of this project, he doesn't really want to learn an other language (like Node.js), because almost everything is a routine for him now in PHP.

I know everything depends on the documentation and what we have to develop exactly, but I'm just a curious mind and want to understand more. I know I have much to make up and sometimes I worry of my current knowledge, but then I think that be whatever big the challenge, there will always be a solution for it.

最满意答案

MVC并不意味着对所有模块(模型,视图,控制器)使用不同的语言,而是松散耦合并封装应用程序的某些部分。

反对许多观点,MVC并不是应用程序开发的灵丹妙药。 这实际上取决于您正在开发的应用程序。

没有必要使用任何框架来遵循MVC方法。 实际上,它是一种可以非常快速地连接在一起的模式,它是最基本的形式。

如果您决定将后端用作API并通过前端提取数据,则无需使用MVC来下地狱或高水位。 例如,对于API,不必执行大多数视图任务。 相反,你应该关心构建一个高性能和可扩展的数据存储层(例如,它能够以多种常见格式轻松提供数据,如XML或JSON)和一个可以很好地处理HTTP请求的强大路由器(看看REST是否是给你的东西)。

在这种情况下,您需要一个可以处理模板的强大前端,并且还具有用于获取,发送和处理数据的强大层。 可以将任务委派给应用程序某些部分的强大控制器层也会派上用场。

那么你看到我在说什么。 这真的取决于你的应用程序。 在我的例子中,后端不会完全遵循MVC方法,而我的前端将完全。 MVC不是为应用程序的某些部分切换编程语言。 相反,它解耦了您的应用程序结构,使事情变得更容易。

当然,在开发这样的企业级应用程序时,框架会派上用场,但并不是必需的。

总结一下:MVC与代码本身没什么关系,它与代码的体系结构和结构有很大关系。 你是如何真正实现它完全取决于你。

MVC does not mean to use differenct languages for all of the modules (model, view, controller), but to loose couple and encapsulate certain parts of your application.

Against many opinions, MVC is not the panacea for application development. It really depends on the application you're developing.

It's not necessary to use any frameworks in order to follow the MVC approach. In fact it's a pattern that can be tied together very quickly, in it's most basic form.

If you decide to use your backend as an API and pull the data via frontend, you don't need to use MVC come hell or high water. For an API for example it's not necessary to perform most of the view tasks. Instead you should care about building a performant and scalable data storage layer (which for example is able to easily provide your data in many common formats, such as XML or JSON) and a strong router that can handle HTTP Requests nicely (See if REST is something for you).

In this case you want a strong frontend which can handle templates, and also has a strong layer for obtaining, sending and handling data in general. A strong controller layer that can delegate tasks to certain parts of your application would also come in handy.

Well you see what I'm talking about. It really depends on your application. In my example the backend wouldn't exactly follow the MVC approach, while my frontend would completely. MVC isn't about switching programming languages for certain parts of your application. Instead it decouples your application structure making things a lot easier.

Of course Frameworks come in handy when developing such an enterprise scale application, but it's not necessarily required.

To sum things up: MVC has not much to do with the code itself, it has much more to do with architecture and structure of your code. How exactely you're implementing it is absolutely up to you.

更多推荐

本文发布于:2023-08-07 21:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466399.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:框架   MVC   closed   framework

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!