根据concreate类设计场景 [英] Design a Scenario based on concreate class

查看:69
本文介绍了根据concreate类设计场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个具体的类包含5个方法而且5个方法中的另一个cass只想使用2个方法而另一个类想要用户休息3方法,我们将如何在模块化编程中执行此操作?

解决方案

访问说明符不指定授予访问权限的主题,例如使用访问权限的类型。如果访问修饰符是私有,则任何类都不访问该成员,是公共 - 所有类都可以访问它,依此类推。请参阅文档并为您的代码设计得出结论: https://docs.oracle.com /javase/tutorial/java/javaOO/accesscontrol.html [ ^ ]。



本文末尾给出了一些经验法则建议。



您可以使用的一种设计方法是在不同的类之间拆分这些2和3方法,但它永远不会是您想要的方式。也许缺少你正在寻找的功能导线,你可以认为这是一个限制,实际上刺激了比你记住的更好的设计决定.a



-SA

If a concrete class contain 5 method and out of 5 method one another cass want to use only 2 method and another class want to user rest 3 method , how we will do this in modular programming?

解决方案

Access specifiers don't specify the subject of granting access, such as types where the access is used. If the access modifier is "private", the member is not accessed by any classes, is "public" — it is accessed by all classes, and so on. Please see the documentation and draw your conclusion for your code design: https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html[^].

The end of this article give some rule-of-thumb recommendations.

One of design approaches you can use is to split those 2 and 3 methods between different classes, but it will never be the way you wanted. And perhaps the lack of the feature you are looking for leads, which you may consider as a limitation, actually stimulates better design decisions than those you keep in mind.a

—SA


这篇关于根据concreate类设计场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆