Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constants following PascalCase convention #71

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open

Constants following PascalCase convention #71

wants to merge 21 commits into from

Conversation

kid-cavaquinho
Copy link

@kid-cavaquinho kid-cavaquinho commented Dec 27, 2017

This PR closes/fixes the following issues:

@OGKevin OGKevin self-requested a review December 27, 2017 17:01
@OGKevin OGKevin added this to the 0.12.5 milestone Dec 27, 2017
@OGKevin
Copy link
Contributor

OGKevin commented Dec 27, 2017

@AnTao 😁 Nice on getting the commits right!

And thanks for this pull request!

Copy link
Contributor

@OGKevin OGKevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions and a note regarding environment constants.


private static ApiContext apiContext;
private static ApiContext _apiContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading _ ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it was resharper doing some work 'automatically'. Shall I revert the underscore on all the private variables?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please revert the _, unless there is a style guide entry that is supporting this _ 👍

@@ -58,8 +58,8 @@ private static string UploadAvatarAndGetUuid(byte[] fileContentByte)
{
var customHeaders = new Dictionary<string, string>
{
{ApiClient.HEADER_ATTACHMENT_DESCRIPTION, ATTACHMENT_DECSRIPTION},
{ApiClient.HEADER_CONTENT_TYPE, CONTEN_TYPE},
{ApiClient.HeaderAttachmentDescription, ATTACHMENT_DECSRIPTION},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATTACHMENT_DECSRIPTION is still in caps.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have missed this ones, changing it.

{ApiClient.HEADER_ATTACHMENT_DESCRIPTION, ATTACHMENT_DECSRIPTION},
{ApiClient.HEADER_CONTENT_TYPE, CONTEN_TYPE},
{ApiClient.HeaderAttachmentDescription, ATTACHMENT_DECSRIPTION},
{ApiClient.HeaderContentType, CONTEN_TYPE},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONTEN_TYPE is still in caps.

There seems to be a few constants in this file that have not been refactored, please refactor them.


private readonly HttpClient client;
private readonly HttpClient _client;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading _ ?


private readonly ApiContext apiContext;
private readonly ApiContext _apiContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading _?


private static bool isInitialized;
private static bool _isInitialized;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading _?


public SessionToken SessionToken { get; private set; }
private readonly Id id;
private readonly PublicKeyServer publicKeyServer;
private readonly Id _id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading _ ?

private readonly Id id;
private readonly PublicKeyServer publicKeyServer;
private readonly Id _id;
private readonly PublicKeyServer _publicKeyServer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading _ ?

@bunq bunq deleted a comment Dec 27, 2017
Copy link
Contributor

@OGKevin OGKevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that I have been sloppy with the initial constants names!

  • Please rename the constants as I’ve pointed out.

private const string PAYMENT_AMOUNT_EUR = "0.01";
private const string PAYMENT_CURRENCY = "EUR";
private const string PAYMENT_DESCRIPTION = "C# test Payment";
private const string Amount = "0.01";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this back to PaymentAmountEur as Amount can also refer to the Amount object.

private const string PAYMENT_CURRENCY = "EUR";
private const string PAYMENT_DESCRIPTION = "C# test Payment";
private const string Amount = "0.01";
private const string Currency = "EUR";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this back to PaymentCurrecnyEur

private const string PAYMENT_DESCRIPTION = "C# test Payment";
private const string Amount = "0.01";
private const string Currency = "EUR";
private const string Description = "C# test Payment";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this back to PaymentDescription. This is our standard on how to name constants. There should be a group identifier and in this case it is Payment.

{Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)},
{Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION},
{Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF}
{Payment.FIELD_AMOUNT, new Amount(Amount, Currency)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to refactor the renames on these lines as well.

private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment";
private const string FIELD_STATUS = "ACCEPTED";
private const int INDEX_FIRST = 0;
private const string Amount = "0.01";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, here I was kinda sloppy with the constants name 🙈, Please rename them as described in my comment above.

private const string TAB_ITEM_FIELD_DESCRIPTION = "Super expensive java tea";
private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT";
private const string TabDescription = "Pay the tab for Java test please.";
private const string StatusOpen = "OPEN";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TabStatusOpen

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OGKevin it should be TabUsageSingleStatusOpen following the style you describe above regarding the group, right? naming is hard

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnTao Naming is indeed hard! 😁 but you will get used to it!

Yes TabUsageSingleStatusOpen sounds good 👍

private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT";
private const string TabDescription = "Pay the tab for Java test please.";
private const string StatusOpen = "OPEN";
private const string Amount = "42.00";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TabAmountEur

private const string TabDescription = "Pay the tab for Java test please.";
private const string StatusOpen = "OPEN";
private const string Amount = "42.00";
private const string Currency = "EUR";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TabCurrencyEur

private const string Amount = "42.00";
private const string Currency = "EUR";
private const string TabItemDescription = "Super expensive java tea";
private const string StatusWaiting = "WAITING_FOR_PAYMENT";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TabStatusWaiting

{TabUsageSingle.FIELD_STATUS, FIELD_STATUS_OPEN},
{TabUsageSingle.FIELD_AMOUNT_TOTAL, new Amount(AMOUNT_EUR, FIELD_CURRENCY)}
{TabUsageSingle.FIELD_DESCRIPTION, TabDescription},
{TabUsageSingle.FIELD_STATUS, StatusOpen},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to refactor these lines after the constants renames.

@bunq bunq deleted a comment Dec 28, 2017
Copy link
Contributor

@OGKevin OGKevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future proofing and some small consistency comments.

We're almost there! 👍 👏 @AnTao

private const string MonetaryAccountBankSubStatus = "REDEMPTION_VOLUNTARY";
private const string MonetaryAccountBankReason = "OTHER";
private const string MonetaryAccountBankReasonDescription = "Because this is a test";
private const string MonetaryAccountBankCurrency = "EUR";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this name future proof, MonetaryAccountBankCurrencyEur. If we start supporting other currencies then there will be less names to change 👍

private const string Description = "Payment From C# Test";
private const string Text = "test msg send from C# test";
private const string PaymentChatAmountEur = "0.01";
private const string PaymentChatCurrency = "EUR";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please suffix the currency Eur

private const string TabUsageSingleDescription = "Pay the tab for Java test please.";
private const string TabUsageSingleStatusOpen = "OPEN";
private const string TabAmountEur = "42.00";
private const string TabCurrency = "EUR";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please suffix Eur and consistency

private const string StatusWaiting = "WAITING_FOR_PAYMENT";
private const string TabUsageSingleDescription = "Pay the tab for Java test please.";
private const string TabUsageSingleStatusOpen = "OPEN";
private const string TabAmountEur = "42.00";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent 😝 TabAmountEur -> TabUsageSingleAmountEur

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant is also used along with the TabItemShop entity. Changing it for consistency!

@bunq bunq deleted a comment Dec 28, 2017
Copy link
Contributor

@OGKevin OGKevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small test amount comment.

After that LGTM

private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT";
private const string TabUsageSingleDescription = "Pay the tab for Java test please.";
private const string TabUsageSingleStatusOpen = "OPEN";
private const string TabUsageSingleAmountEur = "42.00";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 42.00 is way to much :P it will drain the test account pretty fast haha! Please lower this amount.

@bunq bunq deleted a comment Dec 28, 2017
OGKevin
OGKevin previously approved these changes Dec 28, 2017
Copy link
Contributor

@OGKevin OGKevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OGKevin
Copy link
Contributor

OGKevin commented Dec 28, 2017

@sandervdo you're up, please 👀

@OGKevin
Copy link
Contributor

OGKevin commented Dec 28, 2017

Total tests: 36. Passed: 36. Failed: 0. Skipped: 0.

All tests are passing. 👏.

Because this PR doenst need any extra tests, I'm marking the Tested task as done.

Copy link
Contributor

@sandervdo sandervdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all your work in this PR! I mostly have very small comments, some names are plural whereas our convention is to not use plural names at all (we use PaymentIds -> allPaymentId for instance). Some comments will require a second look of @OGKevin as he's the SDK hero. 😄

private const string MESSAGE_LATEST_PAGE_IDS = "Latest page IDs: ";
private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: ";
private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!";
private const string MessageLatestPageIds = "Latest page IDs: ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plural -> MessageLatestPageAllPaymentId

private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: ";
private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!";
private const string MessageLatestPageIds = "Latest page IDs: ";
private const string MessageSecondLatestPageIds = "Second latest page IDs: ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plural -> MessageSecondLatestPageAllPaymentId

private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!";
private const string MessageLatestPageIds = "Latest page IDs: ";
private const string MessageSecondLatestPageIds = "Second latest page IDs: ";
private const string MessageNoPriorPaymentsFound = "No prior payments found!";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plural -> MessageNoPriorPaymentFound

};
Console.WriteLine(MESSAGE_LATEST_PAGE_IDS);
var paymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID,
Console.WriteLine(MessageLatestPageIds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MessageLatestPageAllPaymentId

paginationCountOnly.UrlParamsCountOnly);
PrintPayments(paymentResponse.Value);
var pagination = paymentResponse.Pagination;

if (pagination.HasPreviousPage())
{
Console.WriteLine(MESSAGE_SECOND_LATEST_PAGE_IDS);
var previousPaymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID,
Console.WriteLine(MessageSecondLatestPageIds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename (check for other occurrences too of renamed constants)

@@ -34,4 +34,6 @@ same directory, fill in your sandbox user data and rename the copy to `config.js

## Execution
To run tests via Rider, you can right click on the `BunqSdk.Tests` solution and should be able to run
the tests cases form the IDE.
the tests cases from the IDE.
To run the tests via Visual Studio, you can use the Test Explorer window. Use default shortcut Ctrl+R, A
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a shortcut for the Mac edition of Visual Studio too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For VS Code there is an [extension] (https://github.com/formulahendry/vscode-dotnet-test-explorer) for testing. Although I use VS Code more and more frequently, I still do 95% of .NET development with Visual Studio, so I don't have much feedback on this extension, yet. I am also not sure if this shortcut will work with VS Code.

Are you guys using Rider? What is your feedback? (Sorry for the off topic of the PR)

Copy link
Contributor

@OGKevin OGKevin Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I use Rider, please list this extension in the README as well then to ensure that others know that they must install the extension 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnTao myself I don't code in C# at all, but we use the Jetbrains editors mostly yes (PhpStorm, PyCharm, etc.). But in my case, no Rider.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OGKevin can you check for the shortcut on MacOS then?


/// <summary>
/// Minimum time to session expiry not requiring session reset.
/// </summary>
private const int TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS = 30;
private const int TimeToSessionExpiryMinimumSeconds = 30;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimeToSessionExpiryMinimumSecond (hmm, looks weird, @OGKevin 👀 )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️ your suggestion is fine, 🙅‍♂️ plurals.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OGKevin @sandervdo TimeToSessionExpiryAllMinimumSecond 🙈 This renaming changes will bring a lot of breaking changes!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnTao How do you mean ? I only see one usage for it which is here:

TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ow wait shit your right! I understand. Therefore this pull request needs to actually wait for 0.13.0 👍 Because this is indeed a breaking change! Holy crap how did I miss this 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OGKevin actually the ones I changed in ApiContext.cs are all with the private modifier, so that will be alright.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnTao Correct, but the field constants for the generated code for instance all will be used publicly, means current implementations will break!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets continue the breaking change discussion in the issue please 👍


/// <summary>
/// Glue to concatenate the error messages.
/// </summary>
private const string GLUE_ERROR_MESSAGES = "\n";
private const string GlueErrorMessages = "\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrorMessageGlue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GlueAllErrorMessage Group by Glue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the Glue too much. Why don't we use Separator or sth?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm well Separator can also be used just fine 👍

private const string DeviceServerUrl = "device-server";
private const string InstallationUrl = "installation";
private const string SessionServerUrl = "session-server";
private static readonly string[] UrisNotRequiringActiveSession = new string[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AllUriNotRequiringActiveSession

private const string HEADER_NAME_PREFIX_X_BUNQ = "X-Bunq-";
private const string DELIMITER_HEADER_VALUE = ",";
private const string FORMAT_HEADER_STRING = "{0}: {1}";
private const string Newline = "\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OGKevin do you want these constants grouped as well? Could use Format prefix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeas Format prefix would indeed be great 👌.

@OGKevin OGKevin modified the milestones: 0.12.5, 0.13.0 Dec 28, 2017
@bunq bunq deleted a comment Dec 28, 2017
@OGKevin
Copy link
Contributor

OGKevin commented Dec 28, 2017

@AnTao FYI I've pushed some minor changed, be sure to pull before you push new changes 👍

@kid-cavaquinho
Copy link
Author

Thanks for the push @OGKevin

@OGKevin
Copy link
Contributor

OGKevin commented Dec 29, 2017

@AnTao I dont understand ? Why did you close this pull request ? There is nothing wrong with it!

@OGKevin OGKevin reopened this Dec 29, 2017
@kid-cavaquinho
Copy link
Author

@OGKevin I did not even noticed I've closed it. My bad! Thanks for re-opening it.

@OGKevin OGKevin modified the milestones: 0.13.0, 0.13.5 Mar 27, 2018
@OGKevin OGKevin modified the milestones: 1.0.0, 1.1.0 Jul 24, 2018
@angelomelonas angelomelonas removed this from the 1.1.0 milestone Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename constants to PascalCase
4 participants