简体   繁体   English

设计模式挫折

[英]Design pattern frustrations

I am a developer having 4 years of .Net coding experience, And never cared much about design patterns in my carreer. 我是一名拥有4年.Net编码经验的开发人员,从不关心我的设计模式。 Recently i have been called for an interview with one of the biggies in the IT, have done 5 rounds (problem solving, pair prograaming , logical reasoning, 2 rounds of tech interview) of interview and didnt offer a job. 最近我被要求接受IT部门的一位大佬的采访,已经完成了5轮(解决问题,配对编程,逻辑推理,2轮技术面试)的采访,并没有提供工作。

The feedback i got from them is am not good at design principles though they are satisfied with my technical & logical reasoning skills. 我从他们那里获得的反馈是不擅长设计原则,尽管他们对我的技术和逻辑推理技巧感到满意。 This one made me think that knowing design patterns are the only way to solve the problems? 这个让我觉得知道设计模式是解决问题的唯一方法吗?

Though i never used much of a design patterns in my coding, i always tried to implelement the basic principles of OOPS 虽然我从未在编码中使用过很多设计模式,但我总是试图实现OOPS的基本原理

I could use these principles to design a system thats loosely coupled and open for enhancements and easy to maintain. 我可以使用这些原则来设计一个松散耦合和开放的系统,以增强和易于维护。 Eventtually these are the core constructs of all the design patterns. 事实上,这些是所有设计模式的核心结构。

But my problem is to find a right pattern for the right problem. 但我的问题是为正确的问题找到一个正确的模式。 I know this knowledge will not come by just reading all the books published in design patterns and practises. 我知道只有阅读设计模式和实践中出版的所有书籍才能获得这些知识。 this knowledge comes with the experience of building different systems. 这些知识伴随着构建不同系统的经验。

Is there any use cases available for the pattern-problem matching .. And your suggestion on learning design principles? 是否有任何用例可用于模式问题匹配 ..您对学习设计原则的建议是什么?

Cheers 干杯

Though I think it cannot hurt to become more familiar with design patterns , I want to make sure that there's not a conflation of two things in your question. 虽然我认为变得更熟悉设计模式并不会有什么坏处,但我想确保你的问题中没有两个东西的混合。 You said that the feedback you got was that your ability to apply design principles was weak, and you concluded from that feedback that you need to study design patterns . 你说你得到的反馈是你应用设计原则的能力很弱,你从反馈中得出结论,你需要研究设计模式 But that's different. 但那是不同的。

A "design pattern" is a recurring pattern that you see across many different domains. “设计模式”是您在许多不同域中看到的重复模式。 For example, in architecture you see the pattern of "interior courtyard" in many different kinds of buildings. 例如,在建筑中,您可以在许多不同类型的建筑物中看到“内部庭院”的图案。 In programming you see patterns like "class that can only have a single instance" or "little hunk of code that glues this to that" in many different kinds of programs. 在编程中,您可以在许多不同类型的程序中看到类似“只能拥有单个实例的类”或“将这一点与此相关的一小块代码”的模式。

But principles are not patterns. 但原则不是模式。 A pattern is a particular recurring sort of design; 模式是一种特殊的反复出现的设计; a principle is an idea that underlies what makes a design good for the users of the artifact being designed. 原则是一个构思的基础,这个构思使得设计对于正在设计的工件的用户有益

For example, a design principle of the JScript language is "be forgiving of small errors". 例如,JScript语言的设计原则是“容忍小错误”。 If you make a date object for November 31st, it will silently correct that to December 1st instead of giving an error. 如果您在11月31日创建了一个日期对象,它将默默地将其更正为12月1日,而不是给出错误。 There's no "small error forgiveness pattern". 没有“小错误的宽恕模式”。 Making a design error-tolerant is a design principle -- when we have a choice on how to design a particular feature we consider how well it aligns with all the principles -- some of which are contradictory -- and use those to guide the design of the feature. 设计容错是一个设计原则 - 当我们可以选择如何设计一个特定的特征时,我们会考虑它与所有原则的一致性 - 其中一些是矛盾的 - 并用它们来指导设计的功能。

This is not a design principle of C#; 不是 C#的设计原则; in fact, the opposite is a design principle of C#. 实际上,相反的是C#的设计原则。 Design principles are not good or bad in of themselves; 设计原则本身并不好或坏; they are guidelines for what makes a design good for its target set of users . 它们是使设计适合其目标用户群的指导原则。

Writing code without understanding patterns means not having the tools in your toolbox that make doing common tasks easier. 编写代码而不理解模式意味着没有工具箱中的工具可以更轻松地完成常见任务。 Writing code without understanding design principles means writing code that is inconsistent, hard to comprehend, and contrary to the needs of its users. 编写代码而不理解设计原则意味着编写不一致,难以理解且与用户需求相反的代码。 Both are important but they are very different. 两者都很重要,但它们非常不同。

Design patterns are called patterns because they keep showing up time and time again in many independent programs, not because they're used to put together programs in the same way that squares are stitched together to make a quilt. 设计模式被称为模式,因为它们在许多独立程序中一次又一次地显示出来,而不是因为它们习惯于将方块拼接在一起以便将方块缝合在一起以制作被子。 They can help lead to a solution for a software problem, but they are not a solution in and of themselves. 它们可以帮助解决软件问题,但它们本身并不是解决方案。

Even though you use C#, I'd suggest going through some of the books on patterns. 即使您使用C#,我也建议您浏览一些有关模式的书籍。 First would be the GoF book - Design Pattens . 首先是GoF书 - Design Pattens Then try reading some book on Enterprise Design Patterns. 然后尝试阅读一些关于企业设计模式的书。 As you read, you'll recognize (or see) the Pattern. 在阅读时,您将识别(或看到)模式。 This is generally an "Aha" moment. 这通常是一个“啊哈”的时刻。

You'll also recognize the same from your own code. 您也可以从自己的代码中识别出相同的内容。 Knowing patterns will help you in good designing. 了解模式将有助于您进行良好的设计。 It helps in knowing the patterns as you'll immediately recall the pattern when a problem related to it arises. 它有助于了解模式,因为当出现与之相关的问题时,您会立即回忆起模式。

The programming principles you specified are good and DO follow them. 您指定的编程原则很好,并且遵循它们。 However they are more at a class level. 然而,他们更多的是在班级。 Moving higher up to the System design, Patterns will be more helpful. 向上移动到系统设计,模式将更有帮助。

Most importantly - Patterns give you a vocabulary to discuss design ideas with whole team. 最重要的是 - 模式为您提供了与整个团队讨论设计理念的词汇。

I am sure that you have used some design patterns if you have been programming for 4 years although you may not be aware that you did. 我确信你已经使用了一些设计模式,如果你已经编程了4年,尽管你可能不知道你做了。

Design pattern will teach you to solve some problem that some one has already gone through and found solution for it. 设计模式将教你解决一些已经经历过的问题并找到解决方案。 and finally documented it for us. 最后为我们记录了它。

If you want to learn design patters you can start with "Head First Design Patterns" it is a great book. 如果你想学习设计模式,你可以从“Head First Design Patterns”开始,这是一本很棒的书。

I'm not sure what you really need is design patterns. 我不确定你真正需要的是设计模式。 You probably need more general understanding of design. 您可能需要对设计有更全面的了解。 Giving more advice on that will be difficult without more info. 如果没有更多信息,就会提出更多建议。

Design patterns (as in GoF style) work best with a particular style of writing code. 设计模式(如GoF风格)最适合使用特定类型的编写代码。 Imagine your classes not as things, but as people. 想象一下,你的课程不是作为事物,而是作为人。 Imagine that these people then communicate to each other, by something like passing notes, or through inter-department mail or something like that. 想象一下,这些人然后通过传递笔记,或通过部门间邮件或类似的东西相互沟通。

In general, the ways in which these people communicate, and the patterns of message flow, are pretty close to the GoF design patterns. 一般来说,这些人沟通的方式和消息流的模式与GoF设计模式非常接近。 The patterns that don't match this are typically 'helpers' that are required to write applications that fit this model. 与此不匹配的模式通常是编写适合此模型的应用程序所需的“帮助程序”。

Try this book, it is funny and gives you not only how to implement the pattern, also when to do it. 试试这本书,它很有趣,不仅为您提供了如何实现模式,还提供了何时实现模式。

http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124 http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM