设计网页界面的最佳设计模式是什么?

发布于 2024-09-04 02:19:26 字数 112 浏览 1 评论 0原文

我正在尝试使用 OOP 构建我的网站界面。为此,我需要将菜单、缩略图、内容框等多个对象连接在一起以形成完整的布局。

我知道 OOP 不用于演示,但无论如何我都需要这样做。谁能帮我解决这个问题吗?

I am trying to build the interface of my WEB site using OOP. For this I need to have several objects like menu, thumbnails, contentBoxes joined together to form a complete layout.

I know OOP is not used for presentation but I need to do it anyway. Can anyone help me on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悟红尘 2024-09-11 02:19:26

你可以从一些非常简单的事情开始,比如所有对象都继承自这个接口或抽象类,其中你有一个名为 render() 的方法,它可以吐出所有 html。 html 的构建由属性的值决定,例如作为链接对象集合的菜单,在渲染中为这些链接构建所有 html。

更进一步,您可以开始对对象的属性进行建模,假设 div 具有子元素,因此您可以允许某些对象(从接口 IBlockElement 继承)将其他对象作为子对象(接口 IInlineElement)。

您可以以当父对象渲染所有子元素时也调用渲染方法的方式实现它。假设你做了 $page->render() 并且所有内部元素都会渲染,吐出你的所有 html。

这主要来自我在 .NET 中开发的经验希望这是有道理的

You can start with something really simple like all object inherit from this interface or abstract class where you have a method called render() that spits all the html out. The building of the html is ditacted by the value of your properties, say a menu as a collection of link objects, in render you build all the html for those links.

Going one step furter you can start modeling the properties of your objects say divs have child elements, so you can allow certain objects (inherit from the Interface IBlockElement) to have other objects as childs (Interface IInlineElement).

You can the implementn implement it in a way that when the parent object renders all child elements render methos is also called. Say you do $page->render() and all the inner elements would render, spitting all your html.

This is mainly from my experience developing in .NET Hope this makes sense

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文