code-structure

Idiomatic approach for structuring Clojure source code [closed]

旧时模样 提交于 2019-12-06 19:46:22
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . I'm interested in how people structure their Clojure source code. Being used to Java, I'm pretty familiar with the paradigm of one class per source code file, bundling all the data and method definitions with appropriate comments and annotations etc. However Clojure offers a

React Native: How to split a file up into multiple files and import them?

纵饮孤独 提交于 2019-12-05 12:26:10
问题 I am writing my first app in react native and my js file is getting pretty big. What is the proper way to split the file up. If i have something like var MyClass = React.createClass({ ... }) Can I save it at myclass.js and include in by some command in another js file? 回答1: In general you can do the following: var MyClass = React.createClass({ ... )} module.exports = MyClass; This way you tell what should be publicly available. And then, in your former big file you can load the contents like

Idiomatic approach for structuring Clojure source code [closed]

人盡茶涼 提交于 2019-12-05 00:52:16
I'm interested in how people structure their Clojure source code. Being used to Java, I'm pretty familiar with the paradigm of one class per source code file, bundling all the data and method definitions with appropriate comments and annotations etc. However Clojure offers a lot more flexibility, and I'm not sure how I should structure my project (likely to end up as a medium sized app, maybe 5,000 lines with three or four distinct subsystems) In particular I'm wrestling with: What guidelines should I use to determine whether code should be in a single namespace vs. separated out into

Requiring same module in multiple files

﹥>﹥吖頭↗ 提交于 2019-12-04 18:23:59
问题 I'm using Underscore.js in my project. Almost all files have this line of code: var _ = require('underscore') . The require function is synchronous so the same file is loaded each time it is used. Is this the right thing to do? Doesn't this affect performance? Instead of this, is it okay to define a global variable in the app.js file? _ = require('underscore') I've read that you shouldn't use global variables, but this seems to be a valid use case. 回答1: From the node.js documentation: Modules

What is a good code structure for api-independent vertex processing? [closed]

南笙酒味 提交于 2019-12-04 17:35:57
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Currently working on a 3D media engine using C# and I have come across a little conundrum. I have my rending loop figured out, I got a great plug-in architecture and content management system and even a material pipeline all planned out. Then engine is planned to use DirectX

What is a good code structure for api-independent vertex processing? [closed]

血红的双手。 提交于 2019-12-03 11:03:53
Currently working on a 3D media engine using C# and I have come across a little conundrum. I have my rending loop figured out, I got a great plug-in architecture and content management system and even a material pipeline all planned out. Then engine is planned to use DirectX and OpenGL (via 'renderer' plug-ins), along with both APIs' programmable pipe-line. Anyways, at the beginning of this week I started on working on the engines abstract layer for processing vertices (I have been dreading this for weeks now). And as some of you know, vertex handling between graphic APIs' is not at all

Cleaning up a large, legacy Java project

百般思念 提交于 2019-12-03 05:33:23
I've been assigned to do some work on a huge Java project, and the influence of several iterations of developers is obvious. There is no standard coding style, formatting, naming conventions or class structure. It's a good day when I come across a class with Javadoc, and unit testing is a happy daydream. So far those of us on the project have been "blending in", adapting to the existing convention of whatever class we're working on, but the time is coming to impose some order and consistency. It's a daunting challenge, and I'm looking for any advice people might have on such a task. Are there

How to deal with Pylint's “too-many-instance-attributes” message?

做~自己de王妃 提交于 2019-12-03 04:30:54
问题 I have just tried to lint some code with Pylint, and the last remaining error is R0902: too-many-instance-attributes (8/7) I understand the rationale behind limiting the number of instance attributes, but seven seems a bit low. I also realise that the linter should not have the last word. However, I would like to know what I should be doing instead of: def __init__(self, output_file=None, output_dir=None): """ Set the frobnicator up, along with default geometries """ self.margin = 30 self.pos

How to deal with Pylint's “too-many-instance-attributes” message?

一世执手 提交于 2019-12-02 16:58:58
I have just tried to lint some code with Pylint, and the last remaining error is R0902: too-many-instance-attributes (8/7) I understand the rationale behind limiting the number of instance attributes, but seven seems a bit low. I also realise that the linter should not have the last word. However, I would like to know what I should be doing instead of: def __init__(self, output_file=None, output_dir=None): """ Set the frobnicator up, along with default geometries """ self.margin = 30 self.pos = [0, 0] self.sep = [5, 5] self.cell = [20, 20] self.frobbr = library.Frobbr() page = self.frobbr.get

When should I use optionals and when should I use non-optionals with default values?

柔情痞子 提交于 2019-11-30 14:48:00
I know the recommended way in Swift is to use: class Address { var firstLine : String? var secondLine : String? } but sometimes I see other developers write their code this way: class Address { var firstLine : String = "" var secondLine : String = "" } Is this the unrecommended way because whenever you have nil you will just crash and there's no outlet for your to recover. Is that right? Or there are some use cases where using non-optionals with default can be good. If so then where? I saw this other question which is asking about efficiency rather than which better suits your needs. I'm