什么是“标准框架”?我们应该构建的代码?

发布于 2024-09-08 06:42:48 字数 440 浏览 10 评论 0原文

我们的情况是,我们有 4 名开发人员,他们有一些空闲时间(大约 3-4 周)。

在我们的代码库中,对于不同的项目,有许多框架类型的代码,我们启动的每个新项目都会重新编写。由于我们有一些空闲时间,我正在创建一组所有项目都可以重复使用的“标准”库,例如:

  1. 缓存
  2. 日志记录

虽然上面的这两个库将依赖于企业库等库,每个新项目都会围绕它编写自己的包装器,等等,因此我们正在整合所有这些代码。

我正在寻找有关您内部构建的在许多项目之间共享的标准库的建议。

为了给您提供一些背景信息,我们构建了 LOB 内部应用程序和面向公众的网站 - 即我们不是销售收缩包装的软件公司,因此我们不需要许可模块之类的东西。

任何想法都将不胜感激 - 我们的开发人员渴望编写一些代码,我非常乐意为他们提供一些从长远来看有利于组织的事情。

干杯

We are in a situation whereby we have 4 developers with a bit of free time on our hands (talking about 3-4 weeks).

Across our code base, for different projects, there are a number of framework-y type of code that is re-written for every new project that we start. Since we have some free time on our hands, I'm in the process of creating a "standard" set of libraries that all projects can re-use, such as:

  1. Caching
  2. Logging

Although these 2 above would rely on libraries such as Enterprise Library, each new project would write its own wrappers around it, etc, so we're consolidating all these code.

I'm looking for suggestions on the standard libraries that you built in-house that is shared across many projects.

To give you some context, we build LOB internal apps and public facing websites - i.e. we are not a software house selling shrink-wrap, so we don't need stuff like a licensing module.

Any thoughts would be much appreciated - our developers are yearning to write some code, and I would very much love to give them something to do that would benefit the organization in the long run.

Cheers

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

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

发布评论

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

评论(6

深巷少女 2024-09-15 06:42:48
  • 单元测试基础设施 - 您可以轻松运行所有单元测试吗?你有单元测试吗?
  • 构建过程 - 您可以仅使用 1 或 2 个命令从头开始构建/部署应用程序吗?
  • Unit Testing Infrastructure - can you easily run all your unit tests? do you have unit tests?
  • Build Process - can you build/deploy an app from scratch, with only 1 or 2 commands?
没︽人懂的悲伤 2024-09-15 06:42:48

我们所做的一些主要工作:

  • 日志记录(使用 TraceSource 周围的一些包装器)
  • 序列化包装器(以便您可以在一行代码中序列化/反序列化)
  • 压缩(.NET 功能的包装器,以便您可以在一个代码中完成此操作代码行)
  • 加密(同样的事情,.NET Framework 功能的包装器,因此开发人员不必一直在 byte[] 中工作)
  • Context - 一个遍历堆栈跟踪以返回数据结构的类包含有关当前调用的所有信息(程序集、类、成员、成员类型、文件名、行号等)
  • 等...

希望有帮助

Some of the major things we do:

  • Logging (with some wrappers around TraceSource)
  • Serialization wrappers (so you can serialize/deserialize in one line of code)
  • Compression (wrappers for the .NET functionality, to make it so you can do this in one line of code)
  • Encryption (same thing, wrappers for .NET Framework functionality, so the developer doesn't have to work in byte[]'s all the time)
  • Context - a class that walks the stack trace to bring back a data structure that has all the information about the current call (assembly, class, member, member type, file name, line number, etc)
  • etc, etc...

Hope that helps

夏见 2024-09-15 06:42:48

好吧,最重要的是,不要重新发明轮子!

花一些时间研究您可以轻松利用的库:

  • 对于日志记录,我强烈推荐 Log4Net
  • 用于测试nUnit
  • 用于模拟,Rhino

另外,看看Inversion of Control Containers,我推荐Castle Windsor

  • 对于索引,我推荐 Solr (在 Lucene 之上)。

接下来,编写一些包装器:

这些应该是您 API 的入口点(公共库,但将其视为 API)。

专注于抽象您在 API 中内部使用的所有库,因此,如果您不想再使用 Log4Net 或 Castle Windsor,您可以通过编写结构良好的抽象并专注于松散耦合的设计模式。

采用域驱动开发:

将 API 视为域和模块化抽象,在内部使用其他常见 API(例如常见数据访问库)。

建议:

我会从一个超级灵活的通用 DAL 库开始,它使得访问任何类型的数据和多种存储介质变得非常容易。

我将使用 Fluent nHibernate 来处理关系数据库,并且将所有方法调用到数据访问实现 LINQ 中,因为它是 ac# 语言功能。

使用 LINQ 查询数据库、索引、文件、xml 等。

ok, most importantly, don't reinvent the wheel!

Spend some time researching libraries which you can easily leverage:

  • For logging I highly recommend Log4Net.
  • For testing nUnit
  • For mocking, Rhino.

Also, take a look at Inversion of Control Containers, I recommend Castle Windsor.

  • For indexing I recommend Solr (on top of Lucene).

Next, write some wrappers:

These should be the entry point of you API (common library, but think of it as an API).

Focus on abstracting all the libraries you use internally in your API, so if you don't want to use Log4Net, or Castle Windsor anymore, you can by writing well structured abstractions and concentrating on loosely coupled design patterns.

Adopt Domain Driven Development:

Think of API(s) as Domains and modular abstractions that internally use other common APIs like you common Data Access library.

Suggestions:

I'd start with a super flexible general DAL library, that makes it super easy to access any type of data and multiple storage mediums.

I'd use Fluent nHibernate for the relational DB stuff, and I'd have all the method calls into the you data access implement LINQ, as it's a c# language feature.

using LINQ to query DBs, Indexes, files, xml etc.

清风夜微凉 2024-09-15 06:42:48

有一件事情可以让所有开发人员忙上一个月:

  1. 在具有代码覆盖率(nUnit 或 VS Code Coverage)的分析器中运行应用程序的单元测试。
  2. 找出哪些领域需要更多测试。
  3. 为这些子系统编写单元测试。

现在,如果系统不是使用 TDD 编写的,那么它很可能会非常单一,并且需要进行大量重构才能引入测试面。希望最终你能得到一个更加模块化、耦合性更少的产品。更具可测试性的系统。

Here is one thing that can keep all developers busy for a month:

  1. Run your apps' unit tests in a profiler with code coverage (nUnit or VS Code Coverage).
  2. Figure out which areas need more tests.
  3. Write unit tests for those sub-systems.

Now, if the system was not written using TDD, chances are it'd be very monolithic and will require significant refactoring to introduce test surfaces. Hopefully, at the end of it you end up with a more modular, less tightly coupled. more testable system.

逐鹿 2024-09-15 06:42:48

我的态度是,人们几乎不应该编写标准库。相反,我们应该重构现有的工作代码,以消除重复并提高易用性和测试的简易性。

结果将非常像“标准库”,除了您会知道它可以工作(每次更改后都重新运行单元测试,对吗?),并且您会知道它将被使用,因为它已经正在被使用。否则,您将面临创建一个出色的标准库但未被使用并且在使用时无法工作的风险。

My attitude is that one should almost never write standard libraries. Instead, one should refactor existing, working code to remove duplication and improve ease of use and ease of testing.

The result will be very much like a "standard library", except that you will know that it works (you reran your unit tests after every change, right?), and you'll know that it will be used, since it was already being used. Otherwise, you run the risk of creating a wonderful standard library that isn't used and doesn't work when it is used.

感情废物 2024-09-15 06:42:48

之前的工作在业务部门整理下一个版本时遇到了一些停机时间。我们做了一些事情,帮助

  • 从 .net reoting 迁移到 WCF
  • 搜索所有开发人员都讨厌使用的代码中的痛点并重构它们
  • 引入一个良好的自动化构建系统,可以运行单元测试并发送电子邮件构建失败。它还会将该版本打包并放置在共享目录中,以便 QA 获取
  • 脚本化的数据库,以便您可以轻松升级数据库,而不是被迫获取被其他开发人员一直在玩的不相关数据污染的过时副本和。
  • 引入了正确的错误跟踪和分类流程
  • 研究了如何从 winforms 迁移到 wpf
  • 查看 CAB(复合应用程序)或插件框架,以便配置变得更简单。 (当时设置和配置需要花费大量时间)

我现在要做的其他事情可能是

  • 看看 Postsharp 来编织横切关注点,这将简化日志记录、异常处理或一遍又一遍地重复代码的地方
  • 看看 Automapper 所以从一种类型到另一种类型的转换是由配置驱动的,而不是在许多地方更改代码。
  • 查看有关 TDD 的教育(如果您不这样做)或 BDD 风格的单元测试。
  • 投入时间简化自动化集成测试。 (由于这很难手动设置和配置,因此往往会在 SDLC 中被丢弃)
  • 等开发工具的可行性

查看 Resharper HTH

A previous job encountered a little down time while the business sorted out what the next version should be. There were a few things we did that helped

  • Migrated from .net reoting to WCF
  • Searched for pain points in the code that all devs just hate to work with and refactor them
  • Introduce a good automated build system that would run unit tests and send out emails for failed builds. It would also package and place that version in a shared directory for the QA to pick up
  • Scripted the DB so that you can easily upgrade the database rather than being forced to take an out of date copy polluted with irrelevant data that other devs have been playing with.
  • Introduced proper bug tracking and triage process
  • Researched how we could migrate from winforms to wpf
  • Looked at CAB (composite application) or plugin frameworks so configuration would get simplier. (At that time setup and configuration was a tremendous amount of time)

Other things I would do now might be

  • Look at Postsharp to weave cross cutting concerns which would simplify logging, exception handling or anywhere code was repeated over and over again
  • Look at Automapper so that conversions from one type to another was driven by configuration rather than changing code in many places.
  • Look at education around TDD (if you dont do it) or BDD style unit tests.
  • Invest time in streamlining automated integration tests. (As this one is difficult to set up and configure manually it tends to get dropped of within SDLC)
  • Look at the viability on dev tools such as Resharper

HTH

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