[英]How to manage a proper structure in a java project
I have encountered with this problem often. 我经常遇到这个问题。 Couldn't think of a way to how to face this.
想不出一种方法来面对这个问题。 Now I got this excellent forum!!
现在我有了这个很棒的论坛! I'm sure experts here will help me with this.
我敢肯定,这里的专家会为我提供帮助。
This is not a problem about a specific code segment like thing. 这不是关于特定代码段之类的问题。 I am capable (as I think) of doing some advance projects in java.
我有能力(按照我的想法)在Java中进行一些高级项目。 It means, simply, I can finish the project to give the exact result.
简而言之,这意味着我可以完成项目以给出确切的结果。
But the problem is, though I can finish it some how, I'm not satisfied with the management of the classes etc. Actually I don't know how to properly manage it. 但是问题是,尽管我可以用某种方式完成它,但是我对类的管理不满意。实际上我不知道如何正确地管理它。 I'll explain considering the project I'm currently working on (I'm not a professional coder, this will be for my self learning).
我将解释考虑当前正在从事的项目(我不是专业编码人员,这是我的自学知识)。
I'm working on a database management system (MySQL + Java). 我正在使用数据库管理系统(MySQL + Java)。 There I'm hoping to implement several features there.
我希望在那里实现一些功能。 The flow will be, roughly, like this.
流程大致是这样的。
1. Login
2. Main window
Main window will be like this. 主窗口将是这样。
In the left panel you can select what you need to do. 在左侧面板中,您可以选择需要执行的操作。
Eg.
*. Add some entries to the database
*. Search database
*. Other..(will be add later)
Can some one please tell me how to manage all those things, two frames and several panels. 有人可以告诉我如何管理所有这些东西吗?两个框架和几个面板。
What I've done is like this. 我所做的就是这样。
I've written a managerClass
which has the main method. 我写了一个具有main方法的
managerClass
。 Then It'll call loginFrame
first. 然后,
loginFrame
首先调用loginFrame
。 After validation, loginFrame
calls a method in managerClass
, to load mainFrame
. 验证之后,
loginFrame
调用的方法managerClass
,加载mainFrame
。 But I keep a reference to the managerClass
in all the frames, panels etc.. as I save all the required info in managerClass
, like user name ect.. 但是我在所有框架,面板等中都保留了对
managerClass
的引用。因为我将所有必需的信息都保存在managerClass
,例如用户名等。
But when modifying and debugging, things become really really difficult. 但是,在修改和调试时,事情变得非常困难。 As I haven't done thing according to any specific rule.
因为我还没有根据任何特定规则进行操作。 I'll have to modify almost all the classes to do a slight modification.
我将不得不修改几乎所有的类来进行一些小的修改。 I've though a lot and sea
我虽然海很多
From what I can understand of your application, your main issue is the coupling between your components and the different layers of the application (presentation, interaction control, domain logic). 据我对您的应用程序的了解,您的主要问题是组件与应用程序不同层(表示,交互控制,域逻辑)之间的耦合。 I would suggest using two design patterns (or styles) that may help here:
我建议使用两种设计模式(或样式),可能会在这里有所帮助:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.