如何减少项目中的重复代码。 [英] how to decrease the repetition code in the project.

查看:116
本文介绍了如何减少项目中的重复代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上在我发送消息概念的项目中,我正在使用一些代码。我正在使用相同的代码,我在我的项目中发送消息。所以我想减少重复。有什么办法吗?现在我想要的是什么时候我发送消息。我应该调用一个类文件,我应该传递所需的参数...

Actually in my project for sending message concept i am using some code. same code i am using where ever i am sending the message in my project. so i want to decrease the repetition. is there any solution. now what i want is when ever i send the message.i should call one class file and i should pass the required parameters...

推荐答案

我建​​议你阅读:最佳编码惯例 [ ^ ]。



您需要做的就是为这些部件创建功能/程序多次使用的代码来实现相同的功能。
I would suggest you to read this: Best Coding Practices[^].

All you need to do is to create function/procedure for for these parts of code that are used many times to achieve the same thing.


使用静态方法创建公共静态类

这里是每次使用的静态美联储。

然后你可以使用sataic类名
create public static class with Static Method
here static methad which u used everytime.
then u can access ur static method with sataic class name


这篇关于如何减少项目中的重复代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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