| Conditions | 15 | 
| Total Lines | 59 | 
| Code Lines | 40 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
Complex classes like dynamodb.CreateTableRequest.ToInput often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | package dynamodb  | 
            ||
| 43 | func (r CreateTableRequest) ToInput() *SDK.CreateTableInput { | 
            ||
| 44 | 	in := &SDK.CreateTableInput{} | 
            ||
| 45 | |||
| 46 | 	if r.TableName != "" { | 
            ||
| 47 | in.TableName = pointers.String(r.TableName)  | 
            ||
| 48 | }  | 
            ||
| 49 | 	if len(r.AttributeDefinitions) != 0 { | 
            ||
| 50 | list := make([]SDK.AttributeDefinition, len(r.AttributeDefinitions))  | 
            ||
| 51 | 		for i, v := range r.AttributeDefinitions { | 
            ||
| 52 | list[i] = v.ToSDK()  | 
            ||
| 53 | }  | 
            ||
| 54 | in.AttributeDefinitions = list  | 
            ||
| 55 | }  | 
            ||
| 56 | 	if len(r.KeySchema) != 0 { | 
            ||
| 57 | list := make([]SDK.KeySchemaElement, len(r.KeySchema))  | 
            ||
| 58 | 		for i, v := range r.KeySchema { | 
            ||
| 59 | list[i] = v.ToSDK()  | 
            ||
| 60 | }  | 
            ||
| 61 | in.KeySchema = list  | 
            ||
| 62 | }  | 
            ||
| 63 | |||
| 64 | in.BillingMode = SDK.BillingMode(r.BillingMode)  | 
            ||
| 65 | |||
| 66 | 	if len(r.GlobalSecondaryIndexes) != 0 { | 
            ||
| 67 | list := make([]SDK.GlobalSecondaryIndex, len(r.GlobalSecondaryIndexes))  | 
            ||
| 68 | 		for i, v := range r.GlobalSecondaryIndexes { | 
            ||
| 69 | list[i] = v.ToSDK()  | 
            ||
| 70 | }  | 
            ||
| 71 | in.GlobalSecondaryIndexes = list  | 
            ||
| 72 | }  | 
            ||
| 73 | 	if len(r.LocalSecondaryIndexes) != 0 { | 
            ||
| 74 | list := make([]SDK.LocalSecondaryIndex, len(r.LocalSecondaryIndexes))  | 
            ||
| 75 | 		for i, v := range r.LocalSecondaryIndexes { | 
            ||
| 76 | list[i] = v.ToSDK()  | 
            ||
| 77 | }  | 
            ||
| 78 | in.LocalSecondaryIndexes = list  | 
            ||
| 79 | }  | 
            ||
| 80 | |||
| 81 | 	if r.ProvisionedThroughput.hasValue() { | 
            ||
| 82 | v := r.ProvisionedThroughput.ToSDK()  | 
            ||
| 83 | in.ProvisionedThroughput = &v  | 
            ||
| 84 | }  | 
            ||
| 85 | 	if r.SSESpecification.hasValue() { | 
            ||
| 86 | v := r.SSESpecification.ToSDK()  | 
            ||
| 87 | in.SSESpecification = &v  | 
            ||
| 88 | }  | 
            ||
| 89 | 	if r.StreamSpecification.hasValue() { | 
            ||
| 90 | v := r.StreamSpecification.ToSDK()  | 
            ||
| 91 | in.StreamSpecification = &v  | 
            ||
| 92 | }  | 
            ||
| 93 | |||
| 94 | 	if len(r.Tags) != 0 { | 
            ||
| 95 | list := make([]SDK.Tag, len(r.Tags))  | 
            ||
| 96 | 		for i, v := range r.Tags { | 
            ||
| 97 | list[i] = v.ToSDK()  | 
            ||
| 98 | }  | 
            ||
| 99 | in.Tags = list  | 
            ||
| 100 | }  | 
            ||
| 101 | return in  | 
            ||
| 102 | }  | 
            ||
| 120 |