coding-style

LaTeX report chapter styles

拟墨画扇 提交于 2019-12-10 19:28:46
问题 How do I change chapter styles in LaTeX report class? I have found something about \makechapterstyle , but it doesn't seem to work on reports (or at least it doesn't work on my report :-) ) I'm prety sure there must be some way to change this. I know that LaTeX is not much of programming, but i dont't know any better place to ask this. 回答1: The package fncychap (pdf) seems to be what you're looking for. With it you should be able to format your chapters quite flexibly without the memoir class

Improvement of package-private classes in Java

ⅰ亾dé卋堺 提交于 2019-12-10 19:02:27
问题 In my experience, package-private visibility for classes in Java is turning out to be redundant. Package-private visibility seems to be based on the premise that a class which is almost-privately used by another class is likely to be kept in the same package. Often this is not the case. Is someone exploring an improved access modifier/alternate mechanism? Problem with trying to use package-private visibility: We are tempted to put functionally unrelated classes in same package to get this

How to force Eclipse wrap that line? [duplicate]

谁都会走 提交于 2019-12-10 18:58:46
问题 This question already has answers here : Eclipse Shortcut to Split Long Strings (4 answers) Closed 6 years ago . Is there a way to make Eclipse wrap the line with the b's to a length of 120 per line? I wasn't able to configure the code formatter to wrap the line. This really drives me crazy... public class Position { public static void i() { error(

Indentation of closing parenthesis

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 18:29:36
问题 I believe the PEP8 style guide says that both some_kind_of_list = [ 1, 2, 3, 4, 5, 6 ] def function_that_takes_long_arguments( long_argument_1, long_argument_2 ): return long_argument_1 and some_kind_of_list = [ 1, 2, 3, 4, 5, 6 ] def function_that_takes_long_arguments( long_argument_1, long_argument_2 ): return long_argument_1 are acceptable, but does it make sense to use one or the other, e.g., if I move onto C++ later on in my life? EDIT Apologies, for a function, the PEP8 style guide

How do I assign the output from a Matlab function to a variable in a single line?

怎甘沉沦 提交于 2019-12-10 18:07:21
问题 Is there a way in matlab to assign the output from a function in matlab to a vector within a single line? For example, this function should assign a perimeter and an area value function [p,a] = square_geom(side) p = perimeter_square(side) a = side.^2 [p,a] however when I try to store the data like this v = square_geom(3) It doesn't work. However it is possible to do it like this [p,a] = square_geom(3) v=[p,a] But that just doesn't look as good as keeping it to a single line. Any ideas? 回答1:

Implicit vs explicit getters/setters in AS3, which to use and why?

和自甴很熟 提交于 2019-12-10 17:19:54
问题 Since the advent of AS3 I have been working like this: private var loggy:String; public function getLoggy ():String { return loggy; } public function setLoggy ( loggy:String ):void { // checking to make sure loggy's new value is kosher etc... this.loggy = loggy; } and have avoided working like this: private var _loggy:String; public function get loggy ():String { return _loggy; } public function set loggy ( loggy:String ):void { // checking to make sure loggy's new value is kosher etc...

Is using prototypes to declare array reference context on subroutine args a Good Thing in Perl?

梦想与她 提交于 2019-12-10 17:16:42
问题 In the linked SO answer, Eric illustrates a way to call a subroutine, which accepts arrays by reference as arguments, and use the prototypes to allow the caller code to pass the array names without using reference operator \@ ; the way built-ins like push @array, $value do. # Original code: sub Hello { my ($x_ref, $y_ref) = @_; ...} Hello(\@x, \@y); # Same thing using array ref prototype: sub Hello (\@\@$) {...} Hello(@x, @y); My question is, is this considered to be a Best Practice? And what

TCPDF page borders?

北战南征 提交于 2019-12-10 17:13:03
问题 I'm trying to achieve simple 1px solid red border around each page generated in TCPDF. Previously using other PDF scripts I was forced to draw a rectangle after doing some rough calculations with getting the page width and height and -20px (to allow for 10px indentation on each side). However I'm unsure how I can achieve a similar result with TCPDF. Does anyone have any experience? 回答1: Here you go (this will draw a black line of 15 points around the current page) $pdf = new TCPDF(PDF_PAGE

Is there any case for which returning a structure directly is good practice?

独自空忆成欢 提交于 2019-12-10 17:10:22
问题 IMO all code that returns structure directly can be modified to return pointer to structure. When is returning a structure directly a good practice? 回答1: Modified how? Returning a pointer to a static instance of the structure within the function, thus making the function non-reentrant; or by returning a pointer to a heap allocated structure that the caller has to make sure to free and do so appropiately? I would consider returning a structure being the good practice in the general case. 回答2:

To iterate or to use a counter, that is the question

时光总嘲笑我的痴心妄想 提交于 2019-12-10 16:57:15
问题 Whenever someone starts using the STL and they have a vector, you usually see: vector<int> vec ; //... code ... for( vector<int>::iterator iter = vec.begin() ; iter != vec.end() ; ++iter ) { // do stuff } I just find that whole vector<int>::iterator syntax sickitating. I know you can typedef vector<int>::iterator VecIterInt , and that is slightly better.. But the question is, what's wrong with good ol': for( int i = 0 ; i < vec.size() ; i++ ) { // code } 回答1: When you use index to perform